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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠