问题
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?
回答1:
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:
- 50ms
- 100ms
- 200ms
- 400ms
- 800ms
- 1.6s
- 3.2s
- 6.4s
- 12.8s
- 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.
回答2:
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.
来源:https://stackoverflow.com/questions/55015113/aws-dynamodb-throttled-write-request-handling