Repeating Throttled DynamoDB Requests

大兔子大兔子 提交于 2019-12-24 10:00:45

问题


I am using the AWS SDK for PHP to interact programmatically with DynamoDB.

I would like to detect if a request to DynamoDB has been throttled so another request can be made after a short delay.

Right now, I am operating under the assumption that throttled requests are not fulfilled. Amazon FAQs suggest that a 400 error is returned when throttling occurs.

So I currently have logic that looks something like this:

for( $i=0; $i<10; $i++ ) {

    $response = $dynamodb->get_item($get_item_args);

    if( $response->isOK() ) {

        break;

    } elseif( $i < 9 ) {

        sleep(1);
    }
}

I suppose this works, but it is a bit dumb. In particular, it will repeat all failed requests, not just throttled requests. If there is a non-resolvable error, I really don't want to repeat the request.

To make this smarter, I'd like to look inside a throttled response for a unique identifier (i.e. a specific error message). But for the life of me, I can't capture (or find anywhere on the internet) a sample throttled response.

What is the best way to compensate for the risk of throttling and maximize the likelihood of a fulfilled request?


回答1:


It turns out, the AWS SDKs will automatically retry throttled requests until success. So my efforts above are unneeded (since I am using the AWS SDK for PHP).

The Handling Errors in Amazon DynamoDB documentation page says the following for the ProvisionedThroughputExceededException error:

The AWS SDKs for Amazon DynamoDB automatically retry requests that receive this exception. So, your request is eventually successful, unless the request is too large or your retry queue is too large to finish.



来源:https://stackoverflow.com/questions/13756952/repeating-throttled-dynamodb-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!