This is a quick summary of how you can walk from understanding the dynamodb cost to make a reservation that can help you to save up to 73%
DDB Billing model (Provisioning, PPR)
DynamoDB tables can be On-Demand mode or Provisioned Capacity mode. On-demand mode is chosen for tables that are highly likely to get unpredictable spikes in Read & Write Capacity units. Provisioned mode is more for predictable workload, but even if you don't utilize all the provisioned RCU & WCU you still pay for what you provision
For table in provision mode, you can Reserve Capacity units. It's a billing discount applied on an hourly basis. There is a saving of 54% per year against the saving of 3 years for 73%.
It is always recommended to make the reservation on the billing account if you have multi-accounts connects together.
Review usage via CW and from Billing consoles
AWS provides very useful DynamoDB metrics, you can use them to work out if a table is being used. It is a such necessary step if you have hundreds of tables and the Consumed* metrics show if you have oversized the table throughput.
throughout the billing console, you can figure out how many EU-Consumed[Write,Read]CapacityUnits-Hrs your total of dynamoDB tables used. You can break the group of tables by using the tags but if you have not an tidy account, you won't be able to find out which table(s) has consumed a lot capacity.
Example breaking the capacity units
Go to the Cost Explorer dashboard, filter in by the API operation to "Committed Throughput" and charge type includes "Usage" you can see the daily cost.
For example the chart is reporting that it has been spent
- Daily Write cost $ 70.58 (EU-WriteCapacityUnit-Hrs)
- Daily Read cost $ 28.23 (EU-ReadCapacityUnit-Hrs )
We can work out the number of WCU and RCU used in a day
- Daily WCU consumed 4000 ( $ 70.58 / 24h / $ 0.000735 )
- Daily RCU consumed 8000 ( $ 28.23 / 24h / $ 0.000147 )
Useful AWS CLI
Retrieve the table's name, its capacities the creation time, and the billing method
aws dynamodb list-table | sed 's/ "//g; s/",//g; s/{//g; s/}//g; /TableNames/d' > list_table_names
list="$(cat list_table_names)"
CONTA=0
for t in $(echo $list); do
((CONTA=$CONTA+1))
echo $CONTA $t
aws dynamodb describe-table --table-name $t --query "Table.[TableName,ProvisionedThroughput.ReadCapacityUnits,ProvisionedThroughput.WriteCapacityUnits,BillingModeSummary.BillingMode,CreationDateTime]" --output text >> table_capacities;
done
Reserving some capacities
Let's consider that we want to benefit from the hourly basis discount and make a reservation of Read and Write capacity units.
The reservation is done at a group of 100 capacity units and for Ireland these are the costs
- $0.000735 per WCU hour = 0.0735 100 WCU hour
- $0.000147 per RCU hour = 0.0147 100 RCU hour
All the tables use a total of 8000 RCU and 4000 WCU
There will need 168 days of On-Demand tables to spend as much as a year provisioned reservation
There will need 251 days of On-Demand tables to spend as much as three years provisioned reservation