DynamoDB Provisioned Throughput
DynamoDB Read and Write Capacity Units
- 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 Write Capacity Unit = 1 x 1 KB Write per second
- 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)
DynamoDB Example Configuration
- Table with 5 x Read Capacity Units and 5 x Write Capacity Units
- This configuration will be able to perform:
- 5 x 4KB Strongly Consistent reads = 20KB per second
- Twice as meny eventually consistent = 40 KB
- 5 x 1KB 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 applcation needs to read 80 items (table rows) per second
- Each item 3KB in size
- you need strongly consistent reads
- First, calculate how many Read Capacity Units needed for each read:
- Size of each item / 4KB
- 3KB / 4KB = .75
- Rounded-up to the nearest whole number, each read will need 1 x Read Capacity Unit per read operation
- Multiplied by the number of reads per second = 80 Read Capacity Units required
Eventually Consistent Reads Calculation
- 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 4KB reads per second, or DOUBLE the throughput of strongly consistent reads
- Size of each item / 4KB
- 3KB / 4KB = .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
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 / 1KB (for Write CApacity Units)
- 512 bytes / 1 KB = .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 = 100 Write Capacity Units required
- Size of each item / 1KB (for Write CApacity Units)
DynamoDB Provisioned Throughput Exam Tips
- Provisioned Throughput is measured in Capacity Units
- 1 x Write Capacity Unit = 1 x 1KB write per second
- 1 x Read Capacity Unit = 1 x 4KB Strongly Consistent Read or 2 x 4KB eventually consistent reads per second
Transactional Read and write Capacity Units
You can use DynamoDB transactional read and write APIs to manage complex business workflows that require adding, updating, or deleting multiple items as a single, all or nothing operation. For example, a video game developer can ensure that players' profiles are updated correctly when they exchange items in a game or make in-game purchases.
With the transaction write API, you can group multiple Put, Update, Delete, and ConditionCheck actions and submet them as a single TransactWriteItems operations that either succeeds or failes as a unit. The same is true for multiple Get actions, which you can group and submit as a single TransactGetItems operation.
Transactional read requests require two read capacity units to perform one read per second for items up to 4 KB. You would calculate the strongly consistent units, then multiply by 2.
TRANSACTIONAL REQUESTS ARE ALL OR NOTHING
Eventually Consistent reads = 1 read capacity unit
Strongly consistent reads = 2 read capacity units
Transactional reads = 4 capacity units
For both transactional read and write, double the amount of units needed to get transactional capacity units. Note, for reading, double the strongly consistent unit.
Extras
- GSI can cause throttling issues with with RCU and WCU
- If you perform heavy write activity on the table, but a global secondary index on that table has insufficient write capacity, then the write activity on the table will be throttled.
- To avoid potential throttling, the provisioned write capacity for a global secondary index should be equal or greater than the write capacity of the base table since new updates will write to both the base table and global secondary index.
- LSI use the RCU and WCU of the main table
- GSI only support Eventual Consistency
- LSI Supports both