AWS DynamoDB 受限制的写入请求处理 [英] AWS DynamoDB Throttled Write Request Handling

查看:24
本文介绍了AWS DynamoDB 受限制的写入请求处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在指定时间限制写入请求的表.我想了解更多关于 AWS-SDK 如何处理它们的信息.

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

就我目前的理解而言,DynamoDB 将向我的 Lambda 返回一个错误.这就是为什么我会在 DynamoDB 表指标中出现用户错误.但是,AWS-SDK 具有错误处理和重试策略,可帮助我重试并将受限制的请求写回表中.对吗?

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?

推荐答案

每次您的应用程序发送超出您能力的请求时,您都会收到来自 Dynamo 的 ProvisionedThroughputExceededException 消息.但是,您的 SDK 会为您处理并重试.默认Dynamo重试时间从50ms开始,默认重试次数为10,默认退避为指数.

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. 50 毫秒
  2. 100 毫秒
  3. 200 毫秒
  4. 400 毫秒
  5. 800 毫秒
  6. 1.6 秒
  7. 3.2 秒
  8. 6.4 秒
  9. 12.8 秒
  10. 25.6 秒

如果在第 10 次重试后您的请求仍未成功,SDK 会将 ProvisionedThroughputExceededException 传递回您的应用程序,您可以随意处理.

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.

请注意,您可以更改 SDK 的默认重试行为.例如

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

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

这意味着您重试 13 次,初始延迟为 200 毫秒.这将使您的请求总共需要 819.2 秒而不是 25.6 秒才能完成.

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.

这篇关于AWS DynamoDB 受限制的写入请求处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆