Dynamo DB - Provisioned Throughput
Provisioned Throughput the mechanism used to defined the capacity and performance requirements in DynamoDB
- DynamoDB Provisioned Throughput is measured in Capacity Units
- When you create your table, you specify your requirements in terms of Read Capacity Units and Write Capacity Units.
- 1 x Read Capacity Unit = 1 x Strongly Consistent Read of 4KB per second OR 2 x Eventually Consistent Reads of 4 KB per second (Default)
- 1 x Write Capacity Unit = 1 x 1KB Write per second
Example Configuration
Table with 5 x Read Capacity Units and 5 x Write Capacity Units. This configuration will be able to perform:
- 5 x 4 KB Strongly Consistent reads = 20 KB per second
- Twice as many Eventually Consistent = 40 KB per second
- 5 x 1 KB Writes = 5 KB per second
If your application reads or writes larger items, it will consume more Capacity Units and will cost you more as well.
Strongly Consistent Reads Calculation
- Your application needs to read 80 items (table rows) per second.
- Each item is 3 KB in size
- You need Strongly Consistent Reads
Solution:
- First, calculate how many Read Capacity Units needed for each read
- Size of each item / 4 KB (For Read Capacity Units)
- 3 KB / 4 KB = 0.75
- Rounded-up to the nearest whole number, each read will need 1 x Read Capacity Unit per operation
- Multiplied by the number of reads per second = 80 Read Capacity Units required
What if you need Eventually Consistent Reads?
- You do the same calculation; however, as this is for Eventually Consistent reads and you get 2 x 4 KB per second - or double the throughput of Strongly Consistent reads.
- Size of each item / 4 KB
- 3 KB / 4 KB = 0.75. Round-up to the nearest whole number = 1
- Multiply by the number of reads per second = 80
- Divide 80 by 2, so you only need 40 Read Capacity Units for Eventually Consistent reads.
Another Read Example
You have an application that needs to read 25 items of 13 KB in size per second. Your application uses eventually consistent reads.
- Size of each item / 4 KB
- 13 KB / 4 KB Rounded up = 4
- Multiply by the number of reads per second (i.e. 4 x 25 items) = 100
- Divide 100 by 2, so you only need 50 RCUs (Read Capacity Units) for eventually consistent reads
Yet Another Read Example
You have an application, which reads 80 items of data every second. Each item consists of 3 KB. Your application uses eventually consistent reads.
- 3 KB / 4 KB = 0.75 rounded up to 1
- 1 x 80 = 80 (which would be the strongly-consistent RCU) but since it's eventually consistent, we can divide by 2 (twice the units) and we get 40 RCU
Write Capacity Units Calculation
You want to write 100 items per second. Each item is 512 bytes in size
- First, calculate how many Capacity Units for each write:
- Size of each item / 1 KB (For Write Capacity Units)
- 512 bytes (i.e. 0.5 KB) / 1 KB = 0.5
- Rounded-up to the nearest whole number, each write will need 1 x Write Capacity Unit per write operation.
- Multiplied by the number of writes per second (i.e. 1 x 100) = 100 Write Capacity Units required
Another Write Example
Be careful on this one (notice minutes vs. seconds; need to convert)
You have a motion sensor, which writes 600 items of data every minute. Each item consists of 5 KB. What should you set the write throughput to?
- 5 KB / 1 KB = 5 KB (whole number, so no need to round-up)
- 600 per minute = 10 per second
- 5 KB x 10 = 50 WCU (Write Capacity Unites)
You can contact AWS to increase preconfigured maximums for Provisioned Throughput You must do this to go beyond 10,000