DynamoDB BatchWriteItem – No Throttling?

In my table “products_1”, I’ve configured 1 capacity unit Read and 1 capacity unit Write.

I’m using AWS PHP SDK to write 8 items into DynamoDB using “BatchWriteItem”. The code returned this response:

Object
(
    [structure:protected] => 
    [data:protected] => Array
        (
            [ConsumedCapacity] => Array
                (
                    [0] => Array
                        (
                            [CapacityUnits] => 8
                            [TableName] => products_1
                        )

                )

            [UnprocessedItems] => Array
                (
                )

        )

)

As you can see, it has used 8 capacity units, which is correct.

But when I checked the Monitor in AWS Console, I couldn’t see any entry in “Throttled Write Requests” charts. I was expecting the write requests would be throttled, since I assume “BatchWriteItem” would write 8 items within a second.

Is my assumption wrong? If not, I’m wondering why the writes don’t show up in “Throttled Write Requests” chart.

Answer

Amazon DynamoDB basically allows for bursts of activity without getting throttled, but if you were to maintain operations/second above your provisioned amount for a period of time, you would start getting throttled.

For non-batch operations, the AWS SDK for PHP also retries throttled requests automatically using an exponential backoff algorithm, so even if you get throttled, you won’t necessarily get an error in your PHP code.

In the case of the batch operations, like you are using here, you will know if you have been throttled, because you will have things show up in the UnprocessedItems part of the response.

Separate, but related: if you are planning up doing a lot of put operations and are concerned about throttling, you should check out the WriteRequestBatch class of the SDK, which uses batching and queuing to make sure that all of your items get put, eventually.