DynamoDB is a managed NoSQL database. The main selling point is that developers won’t experience any operational overheads maintaining it.
Nevertheless, since it’s a proprietary database, the architecture is a real blackbox. AWS said that there are numerous differences from the Dynamo paper and every developer should strictly follows their documentations for the best practice.
One of the challeges in their documentation is to calculate and reserve the total numbers of RCUs/WCUs for tables.
Number of read capacity units (RCUs) – how many read requests can you send per second.
Number of write capacity units (WCUs) – how many write requests can you send per second.
How to calcuate WCUs
- 1 WCU = 1kb data / second
- x WCUs = round(item size kb / 1kb)
Example of WCUs
Requirement: write 5 kb data per second
- round(5kb / 1kb) = 5WCUs
There are 2 types of RCUs:
- Strong consistency (read slower becuase of quorums)
- Eventual consistency (read faster + cheaper price)
How to calcuate RCUs
Strong consistency model: 1 RCU = 4kb of data / second
Eventual consistency model: 0.5 RCU = 4kb of data / second
Formula of strong consistency: x RCUs = round(item size kb / 4kb)
Formula of eventual consistency: x RCUs = (round(item size kb / 4kb)) / 2
Example of RCUs
Requirement: write 20 kb data per second
Strong consistency: round( 20 / 4 ) = 5 RCUs
Eventual consistency: ( round(20 / 4) ) / 2 = 2.5 RCUs
Note: In this post, I’m talking about reserved requests (provisioning). However, recently, there is a new pricing model, “On demand”, which literally is not what I mean in this context.