ORly587498
ORly587498

Reputation: 47

DynamoDB: Does BatchWriteItem use less Write Compute Units than PutItem for a high number of records?

I have about 200 records that I need to write frequently to DynamoDB and I'm trying to see if the BatchWriteItem saves any overhead in terms of WCU versus iterating PutItem 200 times. Other than the number of network requests sent, does BatchWriteItem lower the amount of WCU used?

Upvotes: 3

Views: 2745

Answers (1)

Shailendra
Shailendra

Reputation: 9102

Going with the WCU calculation guide here it looks like BatchWriteItem and PutItem both follows the same rounding off calculation for the size and will have same WCU consumed.

For PutItem, UpdateItem, and DeleteItem operations, DynamoDB rounds the item size up to the next 1 KB. For example, if you put or delete an item of 1.6 KB, DynamoDB rounds the item size up to 2 KB.

BatchWriteItem—Writes up to 25 items to one or more tables. DynamoDB processes each item in the batch as an individual PutItem or DeleteItem request (updates are not supported). So DynamoDB first rounds up the size of each item to the next 1 KB boundary, and then calculates the total size. The result is not necessarily the same as the total size of all the items. For example, if BatchWriteItem writes a 500-byte item and a 3.5 KB item, DynamoDB calculates the size as 5 KB (1 KB + 4 KB), not 4 KB (500 bytes + 3.5 KB).

Upvotes: 6

Related Questions