有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何防止DynamoDBMapper中的ProvisionedThroughoutExceededException?

我有将近300个线程试图访问一个DynamoDB表,但分配的读/写容量非常低(5/秒)。所以负载显然太高了,我从DynamoDBMapper得到ProvisionedThroughputExceededException。问题是:如何使DynamoDBMapper等待+重试而不是失败

我在AmazonDynamoDBClient上使用了ExponentialBackoffStrategy,延迟时间很长(以100ms为基数,12次重试,所以这会产生100ms、200ms、400ms、…409600ms),但它根本不起作用。事实上,它马上就失败了。根据the docs

ProvisionedThroughputExceededException

Message: You exceeded your maximum allowed provisioned throughput for a table or for one or more global secondary indexes. To view performance metrics for provisioned throughput vs. consumed throughput, open the Amazon CloudWatch console.

Example: Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests that receive this exception. Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of requests, using exponential backoff.

我做错了什么

“太大而不能完成”是什么意思

谢谢

如果您想知道为什么我使用300个线程,低分配容量,并且可以接受较长的响应时间:通常我们使用较高的容量,我只是不希望应用程序在容量较低时失败


共 (1) 个答案

  1. # 1 楼答案

    好吧,我有一个错误的重试条件。然后还需要调整最大重试次数,以及可能的延迟(max,base)