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.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ