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
demandé il y a 2 ans1262 vues
1 réponse
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
répondu il y a 2 ans
  • 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.

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions