4
votes

In AWS Dynamodb, does

DynamodbMapper.batchSave(records)

operation is considered as one write operation or it is equal to the number of records?

I am asking in reference of write capacity units. One write capacity unit represents one write per second. So, if I have 10 WCU, then can I save 100 records using one batchSave call and still use only one WCU.

1

1 Answers

5
votes

DynamoDBMapper uses the BatchWriteItem API behind the scenes for the batchSave method. From the BatchWriteItem documentation:

each specified put and delete request consumes the same number of write capacity units whether it is processed in parallel [saved in a batch] or not [saved individually]. Delete operations on nonexistent items consume one write capacity unit.

If you are saving 100 items, you will use at least 100 WCU. A single item uses 1 WCU for each 1kb of data (including attribute names) in the item. The number of WCUs is always rounded up to the nearest whole number, and there’s no “sharing” of partial WCUs between items in the same request.

For example, if you had 10 items which were each 1.2 kb, then writing all of the items would consume 20 WCU.