Core Concepts
- Write Capacity Unit (WCU): Represents one write operation per second for an item up to 1 KB in size.
- Read Capacity Unit (RCU): Represents read operations per second for an item up to 4 KB in size. The number of reads per RCU depends on the consistency model.
- The Rounding Up Rule: For any calculation, DynamoDB always rounds the item size up to the next whole kilobyte. A 1.2 KB item is treated as 2 KB for writes and 4 KB for reads.
1. Write Capacity Unit (WCU) Calculation
The Rule
- 1 WCU can perform 1 standard write per second for an item up to 1 KB.
Step-by-Step Calculation
- Determine Item Size: Find the size of your item in KB.
- Calculate WCUs per Item: Round the item size up to the nearest whole KB.
WCUs_per_item = CEILING(item_size_in_KB / 1_KB)
- Calculate Total WCUs: Multiply the WCUs per item by the number of writes per second.
Total_WCUs = WCUs_per_item * number_of_writes_per_second
Example
You need to perform 10 writes per second for an item that is 2.5 KB in size.
- Item size is 2.5 KB.
- Round up to the nearest KB: 3 KB. This means each write requires 3 WCUs.
- Total WCUs =
3 * 10 = 30 WCUs
.
2. Read Capacity Unit (RCU) Calculation
Read calculations depend on the consistency model you choose.
The Rule
- 1 RCU can perform 1 strongly consistent read per second for an item up to 4 KB.
- 1 RCU can perform 2 eventually consistent reads per second for an item up to 4 KB.
Step-by-Step Calculation
Step A: Calculate the "Read Unit Size" of your item.
- Determine Item Size: Find the size of your item in KB.
- Calculate Read Units: Round the item size up to the nearest multiple of 4 KB, then divide by 4.
Read_Units_per_item = CEILING(item_size_in_KB / 4_KB)
Step B: Use the result from Step A to find your total RCUs.
For Eventually Consistent Reads (Default)
- Calculate Total Read Units per Second:
Total_Read_Units = Read_Units_per_item * number_of_reads_per_second
- Calculate Total RCUs: Divide the total by 2 and round up to the nearest whole number.
Total_RCUs = CEILING(Total_Read_Units / 2)
Example: 100 eventually consistent reads per second for a 9 KB item.
- Step A (Read Unit Size):
CEILING(9 KB / 4 KB) = CEILING(2.25) = 3
. Each read requires 3 "read units".
- Step B (Total RCUs):
- Total Read Units =
3 * 100 = 300
. - Total RCUs =
CEILING(300 / 2) = 150 RCUs
.
- Total Read Units =
For Strongly Consistent Reads
- Calculate Total RCUs: Multiply the "Read Unit Size" by the number of reads per second.
Total_RCUs = Read_Units_per_item * number_of_reads_per_second
Example: 100 strongly consistent reads per second for a 9 KB item.
- Step A (Read Unit Size):
CEILING(9 KB / 4 KB) = 3
. Each read requires 3 "read units".
- Step B (Total RCUs):
- Total RCUs =
3 * 100 = 300 RCUs
.
- Total RCUs =
3. Transactional Operation Calculation
Transactional operations consume double the capacity units of standard operations.
-
Transactional Write:
- Rule: Requires 2 WCUs per write for an item up to 1 KB.
- Calculation: Calculate the WCUs for a standard write, then multiply by 2.
-
Transactional Read:
- Rule: Requires 2 RCUs per read for an item up to 4 KB.
- Calculation: Calculate the RCUs for a strongly consistent read, then multiply by 2.
Example
You need to perform 10 transactional writes per second for a 2.5 KB item.
- Calculate standard WCUs:
CEILING(2.5 KB / 1 KB) * 10 = 3 * 10 = 30 WCUs
. - Apply transactional multiplier:
30 * 2 = 60 WCUs
.
Quick Reference Summary
Operation Type | Item Size | Capacity Units Required |
---|---|---|
Standard Write | 1 KB | 1 WCU |
Transactional Write | 1 KB | 2 WCUs |
Eventually Consistent Read | 4 KB | 0.5 RCU |
Strongly Consistent Read | 4 KB | 1 RCU |
Transactional Read | 4 KB | 2 RCUs |
Sources |