当超出预配置的吞吐量时,该怎么办? [英] What should be done when the provisioned throughput is exceeded?

查看:148
本文介绍了当超出预配置的吞吐量时,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用适用于Java的AWS开发工具包(Node.js)从DynamoDB表读取数据.自动缩放功能在大部分时间中都表现出色,并且一天中的大部分时间消耗的读取容量单位(RCU)确实很低.但是,有一个编程的作业在午夜左右执行,消耗的内存约为预配置的RCU的10倍,并且由于自动缩放需要一些时间来调整容量,因此有很多读取请求受到限制.此外,我怀疑我的请求没有完成(尽管我在错误日志中找不到任何异常).

I'm using AWS SDK for Javascript (Node.js) to read data from a DynamoDB table. The auto scaling feature does a great job during most of the time and the consumed Read Capacity Units (RCU) are really low most part of the day. However, there's a programmed job that is executed around midnight which consumes about 10x the provisioned RCU and since the auto scaling takes some time to adjust the capacity, there are a lot of throttled read requests. Furthermore, I suspect my requests are not being completed (though I can't find any exceptions in my error log).

为了处理这种情况,我已经考虑过使用AWS API增加预配置的RCU(

In order to handle this situation, I've considered increasing the provisioned RCU using the AWS API (updateTable) but calculating the number of RCU my application needs may not be straightforward.

因此,我的第二个猜测是重试失败的请求,只是等待自动扩展增加已配置的RCU.正如AWS文档和一些堆栈溢出答案所指出的(特别是关于 ProvisionedThroughputExceededException ):

So my second guess was to retry failed requests and simply wait for auto scale increase the provisioned RCU. As pointed out by AWS docs and some Stack Overflow answers (particularlly about ProvisionedThroughputExceededException):

用于Amazon DynamoDB的AWS开发工具包会自动重试收到此异常的请求.因此,您的请求最终将成功,除非请求太大或重试队列太大而无法完成.

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.

我已经阅读了类似的问题(这个问题这一个),但我仍然感到困惑:如果请求太大或重试队列太大而无法完成,是否引发此异常(因此是在自动重试之后还是在重试之前?

I've read similar questions (this one, this one and this one) but I'm still confused: is this exception raised if the request is too large or the retry queue is too large to finish (therefore after the automatic retries) or actually before the retries?

最重要的:是我在上下文中应该期待的例外吗? (这样我就可以捕获它并重试,直到自动缩放增加RCU为止?)

Most important: is that the exception I should be expecting in my context? (so I can catch it and retry until auto scale increases the RCU?)

推荐答案

是.

每当您的应用程序发送的请求超出您的能力时,您都会从Dynamo收到ProvisionedThroughputExceededException消息.但是,您的SDK会为您处理此问题,然后重试. Dynamo的默认重试时间开始于50ms,默认重试次数为10,默认情况下,补偿是指数级的.

Every time your application sends a request that exceeds your capacity you get 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.4秒
  • 12.8秒
  • 25.6秒
  • 50ms
  • 100ms
  • 200ms
  • 400ms
  • 800ms
  • 1.6s
  • 3.2s
  • 6.4s
  • 12.8s
  • 25.6s

如果在第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.

您可以通过增加吞吐量来进行处理,但是另一种选择是在创建Dynamo连接时更改默认重试时间.例如

You could handle it by increasing throughput provision but another option would be to change the default retry times when you create the Dynamo connection. For example

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

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

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.

这篇关于当超出预配置的吞吐量时,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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