Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top