4
votes

I am new to DynamoDB and NoSQL. I have 2 x tables setup and they are very small. < 80 items each. one currently 60KB the other 1.5KB. Writes are made on a timed basis twice delay based on an external feed. Reads are made via lambda for API gateway.

I can see already i have made mistakes in my DynamoDB setup and usage of these: I am using scans where i believe i could be using using queries and I have a GSI which could possibly be handled better through better primary key and local secondary index setup, although this is still a mystery to me.

I am getting charged $0.89 extra per day pretty consistently, above the free tier for "per hour for units of read capacity beyond the free tier" $0.15 and "per hour for units of write capacity beyond the free tier" $0.74.

Before making changes to my setup i want to understand why I am incurring the additional cost and where - I am looking at the costs explorer and I can't see the tipping point where the costs are incurred.

Grateful for any pointers

1

1 Answers

4
votes

DynamoDB free tier includes:

  • 25 GB of Storage
  • 25 provisioned Write Capacity Units (WCU)
  • 25 provisioned Read Capacity Units (RCU)

A single write capacity unit is used for writing a single item of below 1kb. If the item is above 1kb (like in your example 1.5kb) then it will use additional capacity units. Your 60kb item would use 60 write capacity units to make this write.

A single read capacity unit is used for reading a single item of below 4kb. The same rules as write capacity applies.

With a scan, the read capacity units usage will always be the total for the entire DynamoDB table. Based on your example 1 60KB item is 15 read capacity units, if another 79 at 1.5kb, thats another 79 capacity units for each item. So 94 in total for a single scan.

The reason for scans using all these capacity units is that the filter is actually applied after he data is retrieved from each partition.

This is where a query is more efficient, the retrieval of items is performed on the partition. Items will be filtered and then consume the total capacity of the items that are returned.

If you want to try and reduce costs, ensure that DynamoDB read and write capacity units are either set at 25 during creation, or that autoscaling cannot surpass 25.

More information here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html