Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB Write capacity used when updating

I am wondering how DynamoDB's write capacity is calculated when updating an existing item that has a ListAttribute.

The generalized concept of the Models are like the following:

Model A
id = UUID
name = Str
...other fields

Model A Map Attribute

Model B
id = UUID
modelA_list = ListAttr[Model A Map Attribute]

As far as I know, the only relevant calculation information is on new writes, where the capacity is calculated by rounding up to the next KB. So for example, if I have total 899 characters(assume alphanumeric) on all the fields combined, it will be total 999 bytes(including the 100 bytes for one item) which would be 1 WCU. If I have 901 characters, then it will be 2 WCU.

However, if I'm using the UpdateItem on a pre-existing item, then would the calculation be for the additional bytes added to the item, or the entire item? So for example, if I had Model A Map Attribute which takes 1 WCU, and model B has 10 of Model A Map Attribute. If I append another Model A Map Attribute to Model B, would it cost 12 WCU?

like image 865
John Suh Avatar asked Jan 28 '23 19:01

John Suh


1 Answers

Here is how you calculate the WCU for updating an item:

DynamoDB considers the size of the item as it appears before and after the update. The provisioned throughput consumed reflects the larger of these item sizes. Even if you update just a subset of the item's attributes, UpdateItem will still consume the full amount of provisioned throughput (the larger of the "before" and "after" item sizes).

Reference: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughput.html#ItemSizeCalculations.Writes

like image 128
Deividi Silva Avatar answered May 28 '23 11:05

Deividi Silva