DynamoDB Calculations for compute units
In DynamoDB you will have to read and write data from the database however unlike for RDS instances, you will be paying per read and write since DynamoDB follows the serverless principles. This means if you choose to provision your read capacity units (RCUs) and write capacity units (WCUs), you'll have to calculate roughly how much your going to use and pay for that provisioned capacity.
On-demand is another option for DynamoDB however this can be costly compared to provisioned capacity units.
There are different types of reads and writes with different calculations which we will go over.
Calculating WCUs
There are two distinct types of WCU calculations you'll need to know.
For WCUs, $$\lceil x \rceil$$ refers to the size being rounded up to the nearest KB
Standard WCUs:
$$\text{WCU}_{\text{Standard}} = \left\lceil \text{ItemSize}_{\text{KB}} \right\rceil \times \text{WritesPerSecond}$$
transactional WCUs:
$$\text{WCU}_{\text{Transactional}} = \left( \left\lceil \text{ItemSize}_{\text{KB}} \right\rceil \times \text{WritesPerSecond} \right) \times 2$$
Transactional WCUs cost more for the additional computation required to make sure the transaction is applied correctly at each stage
Calculating RCUs
For read capacity units, you also have two seperate calculations you'll need to be aware of.
For RCUs, $$\lceil x \rceil$$ refers to the size being rounded up to the nearest 4KB
Eventually consistant (standard reads):
$$RCU_{Ev} = \left\lceil \frac{ItemSize_{KB}}{4} \right\rceil \times ReadsPerSecond \times 0.5$$
Strongly consistent reads:
$$RCU_{Strong} = \left\lceil \frac{ItemSize_{KB}}{4} \right\rceil \times ReadsPerSecond$$
Transactional Reads:
$$RCU_{Trans} = \left\lceil \frac{ItemSize_{KB}}{4} \right\rceil \times ReadsPerSecond \times 2$$
Strongly consistent reads require more effort thus incuring higher costs.
Comments ()