Chester Chak
Chester Chak

Reputation: 51

AWS DynamoDB Throttled Write Request Handling

I have a table which has throttled write request at a specified time. I want to understand more about how AWS-SDK handle them.

For my current understanding, DynamoDB will return an error to my Lambda. That's why I will have user errors in DynamoDB Table Metrics. However, AWS-SDK has error-handling and retry strategy which helps me to retry and write the throttled requests back to the table. Is it correct?

Upvotes: 5

Views: 3383

Answers (2)

F_SO_K
F_SO_K

Reputation: 14799

Every time your application sends a request that exceeds your capacity you get a ProvisionedThroughputExceededException message from Dynamo. However your SDK handles this for you and retries. The default Dynamo retry time starts at 50ms, the default number of retries is 10, and backoff is exponential by default.

This means you get retries at:

  1. 50ms
  2. 100ms
  3. 200ms
  4. 400ms
  5. 800ms
  6. 1.6s
  7. 3.2s
  8. 6.4s
  9. 12.8s
  10. 25.6s

If after the 10th retry your request has still not succeeded, the SDK passes the ProvisionedThroughputExceededException back to your application and you can handle it how you like.

Note that you can change the default retry behaviour of your SDK. For example

new AWS.DynamoDB({maxRetries: 13, retryDelayOptions: {base: 200}});

This would mean you retry 13 times, with an initial delay of 200ms. This would give your request a total of 819.2s to complete rather than 25.6s.

Upvotes: 9

singh30
singh30

Reputation: 1503

If lot of write requests are coming to your dynamoDB table and provisioned write capacity is less the the write requests them DynamoDB throttles your request.

If you implement a retry strategy and use it for failed write than this write may also gets throttled as you are already receiving lot of write requests. This retry strategy will add extra load to your dynamoDB.

The solution for this is to use DynamoDB On-demand mode.

Upvotes: 0

Related Questions