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?