Read Write Capacity Modes
to control the tables capacity we have 2 methods
Provisioned Mode
You specify the number of reads / writes per second
need to plan capacity beforehand
Pay for provisioned read and write capacity units
On demand Mode
Read and write automatically scale up/down with your workloads
No capacity planning needed
pay for what you see, more expensive
you can switch between different modes once every 24 hr
Table must have provisioned read and write capacity units
read capacity units (RCU) quantity for reads
write capacity units (WCU) quantity for writes
option to setup auto-scaling of throughput to meet demand
quantity can be exceeded temporarily using “Burst capacity”
if burst capacity has been consumed you’ll get a “ProvisionedThroughputExceedException”
DynamoDB Write capacity units
one write unit (WCU) represents one write per second for an item up to 1kb in size
if the items are larger than 1 KB more WCU are consumed
all the KB decimal is rounded to up
Strongly consistent read vs eventually consistent read
Eventually Consistent read (by default)
if we read just after a write its possible we’ll get some no consistent data because of replication
Strongly Consistent read
if we read just after write we will get correct data
set consistendRead parameter to true in api calls(getitem, batchGetItem,Query,scan)
consumes twice the RCU
DynamoDB Read Capacity Units(RCU)
One read capacity unit(RCU) represents one Strongly Consistent Read per second or two Eventually Consistent Reads per seconds
for an item up to 4 KB in size
if the items are larger than 4 KB, more RCUs are consumed
Amazon DynamoDB partitions internal
if you have 10 partition and 10 WCU and 10 RCU you have to 1 RCU and 1 WCU per partition
DynamoDB Error
If we exceed provisioned RCU or WCU we get “ProvisionedThrougputExceedException”
Reasons:
Hot key one partition key is being read too many times
hot partitions
Very large items, RCU and WCU depended on size of items
Solutions
Exponential back off when exception is encountered (already in SDK)
Distribute partition keys as much as possible
if RCU issue we can use DynamoDB Accelerator (DAX)
R/W Capacity modes – On-Demand
Read and write automatically scale up/down with your workloads
no capacity planing needed (WCU and RCU )
unlimited WCU and RCU no error, more expensive
you are charged for reads and writes that you use in terms of RRU and WRU
Read request Units (RRU) quantity for reads same as RCU
write request units (WRU) quantity for writes same as WCU
2.5 more expensive than provisioned capacity
use cases unknown workloads unpredictable application traffic
Example of RCU and WCU
To change the RCU and WCU you have to click on Additional settings then click on edit on Read/write capacity
you can test the read and write calculator
here we can edit the RCU and the WCU
if we select on demand we can select max read request and max write
Links:
Leave a Reply
You must be logged in to post a comment.