How do I test my code to handle UnprocessedItems on a BatchWriteItem?

0

I've implemented a BatchWriteItem to write several items at a time into a single table of my DynamoDB database. My table has Provisioned Capacity of 1WCU (deliberately low to try and provoke an error), and I'm trying to write 10 items, so this should be writing 10 items at once which is easily too much for the provisioned 1WCU.

However I am never seeing any UnprocessedItems in the BatchWriteItemOutcome's result. I think this is due to the table's automatic "Burst" handling, which uses unused capacity from the previous few minutes to allow this burst of writing. While handy, this isn't helping me to test my code - so I wonder if there is a way of turning this off.

I have tried the following:

  • implementing my own RetryStrategy (which simply returns a MaxAttempts of 1 and ShouldRetry = false)
  • Running the code to write the 10 items several times, in a loop. (When I do this, after a few retries I do get a "ProvisionedThroughputExceededException", but the UnprocessedItems is still empty).

So how do I test my processing of UnprocessedItems, if I never get any reported to me...? I'm using the AWS C++ SDK.

Thanks!

Liam

Liam
已提问 2 年前1262 查看次数
1 回答
0

Right, you're benefitting from the burst bucket which tracks unutilized capacity over the previous 5 minutes. If your table has been fully idle for 5 minutes then you'll have 300 WCUs in the burst bucket when you start the test. Just make sure your test consumes that burst capacity amount and then you'll get the throttling you seek. Tip: If you make your items larger you can consume the capacity with fewer requests.

AWS
已回答 2 年前
  • Hi, many thanks for your reply. I did stick my code in a loop, running 10- times in quick succession, and sure enough the BatchWriteItem failed with a ProvisionedThroughputExceededException - but the UnprocessedItems was still empty.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则