0
0
DynamoDBquery~5 mins

On-demand vs provisioned cost comparison in DynamoDB

Choose your learning style9 modes available
Introduction
You want to understand how much it costs to use DynamoDB with different billing methods so you can choose the best one for your needs.
When you have unpredictable or variable traffic to your database.
When you have steady and predictable traffic and want to save money.
When you want to avoid paying for unused capacity.
When you want to control costs by setting limits on read/write capacity.
When you want to quickly start without capacity planning.
Syntax
DynamoDB
No direct query syntax; cost comparison is done by analyzing usage and pricing models.
On-demand charges you per request, no capacity planning needed.
Provisioned requires setting read/write capacity units in advance.
Examples
You pay only for what you use, good for unpredictable workloads.
DynamoDB
On-demand pricing: Pay per read/write request unit used.
You pay for the capacity you reserve, good for steady workloads.
DynamoDB
Provisioned pricing: Set read/write capacity units (RCUs/WCUs) ahead.
Sample Program
This example shows how to calculate monthly costs for both pricing models using sample usage and rates.
DynamoDB
-- Example calculation for cost comparison
-- Assume 1 million read requests and 500,000 write requests in a month
-- On-demand pricing (example rates):
-- Read request unit = $0.00025
-- Write request unit = $0.00125
-- Provisioned pricing:
-- 50 RCUs at $0.00013 each per hour
-- 25 WCUs at $0.00065 each per hour

-- Calculate on-demand cost:
SELECT
  1000000 * 0.00025 AS on_demand_read_cost,
  500000 * 0.00125 AS on_demand_write_cost,
  (1000000 * 0.00025) + (500000 * 0.00125) AS on_demand_total_cost;

-- Calculate provisioned cost for 30 days (720 hours):
SELECT
  50 * 0.00013 * 720 AS provisioned_read_cost,
  25 * 0.00065 * 720 AS provisioned_write_cost,
  (50 * 0.00013 * 720) + (25 * 0.00065 * 720) AS provisioned_total_cost;
OutputSuccess
Important Notes
On-demand is flexible but can be more expensive if usage is high and steady.
Provisioned is cheaper for steady workloads but you pay even if you don't use all capacity.
You can switch between modes based on your usage patterns.
Summary
On-demand charges per request, no setup needed.
Provisioned requires capacity planning but can save money for steady use.
Choose based on your workload predictability and cost preferences.