On-demand vs provisioned cost comparison in DynamoDB - Performance Comparison
When using DynamoDB, it's important to understand how costs grow as your data and traffic increase.
We want to see how the cost changes when using on-demand versus provisioned capacity modes.
Analyze the cost behavior of these two capacity modes.
// On-demand mode: charges per request
// Provisioned mode: charges per capacity unit reserved
// Example usage:
// On-demand: pay for each read/write request
// Provisioned: pay fixed units, regardless of usage
This shows how DynamoDB charges differently based on your capacity mode choice.
Look at what causes costs to repeat or grow.
- Primary operation: Number of read/write requests made to the database.
- How many times: Each request counts separately in on-demand mode; fixed in provisioned mode.
Costs grow differently depending on mode and request volume.
| Request Volume (n) | On-demand Cost | Provisioned Cost |
|---|---|---|
| 10 | Low (pay per request) | Fixed (capacity units reserved) |
| 100 | Moderate (more requests, more cost) | Fixed (same reserved units) |
| 1000 | High (cost grows with requests) | Fixed or may need to increase capacity |
Pattern observation: On-demand cost grows linearly with requests; provisioned cost stays fixed until capacity is increased.
Time Complexity: O(n) for on-demand mode cost growth
This means cost grows directly with the number of requests you make.
[X] Wrong: "Provisioned mode cost grows with every request just like on-demand."
[OK] Correct: Provisioned mode charges a fixed rate for reserved capacity, not per request, so cost stays stable until you increase capacity.
Understanding how costs scale with usage helps you design efficient and cost-effective DynamoDB solutions.
What if you switch from on-demand to provisioned mode but your request volume suddenly doubles? How would the cost behavior change?
Practice
Solution
Step 1: Understand billing modes in DynamoDB
DynamoDB offers two main billing modes: on-demand and provisioned. On-demand charges per request without pre-allocating capacity.Step 2: Identify the mode with no upfront capacity planning
On-demand mode does not require capacity planning and bills you based on actual usage.Final Answer:
On-demand mode -> Option CQuick Check:
On-demand charges per request = On-demand mode [OK]
- Confusing provisioned mode as pay-per-request
- Thinking reserved mode exists in DynamoDB billing
- Assuming manual mode is a billing option
Solution
Step 1: Recall DynamoDB table creation syntax for provisioned mode
Provisioned mode requires specifying ProvisionedThroughput with ReadCapacityUnits and WriteCapacityUnits.Step 2: Match the correct syntax
ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } uses the exact correct keys: ProvisionedThroughput with ReadCapacityUnits and WriteCapacityUnits.Final Answer:
ProvisionedThroughput: { ReadCapacityUnits: 5, WriteCapacityUnits: 5 } -> Option AQuick Check:
Provisioned capacity uses ProvisionedThroughput [OK]
- Using BillingMode for provisioned capacity
- Incorrect key names like CapacityUnits or Throughput
- Confusing ON_DEMAND with provisioned syntax
Solution
Step 1: Analyze usage vs provisioned capacity
The app uses 8 reads and 3 writes per second, which is below the provisioned 10 reads and 5 writes capacity.Step 2: Compare cost implications
Provisioned mode charges fixed capacity regardless of usage, so if usage is steady and below provisioned, it is cheaper than on-demand which charges per request.Final Answer:
Provisioned mode -> Option DQuick Check:
Steady low usage < provisioned = Provisioned cheaper [OK]
- Assuming on-demand is always cheaper
- Ignoring provisioned capacity limits
- Thinking cost depends only on data size
Solution
Step 1: Identify the mismatch between capacity and usage
The app needs 20 reads per second but provisioned capacity is only 5 reads, causing throttling.Step 2: Determine the fix
To fix, increase provisioned capacity or switch to on-demand mode which scales automatically.Final Answer:
Provisioned capacity too low; increase capacity or switch to on-demand -> Option AQuick Check:
Low provisioned capacity causes throttling; increase or switch [OK]
- Confusing on-demand and provisioned modes
- Reducing capacity when usage is high
- Ignoring throttling symptoms
Solution
Step 1: Understand startup needs
They want to handle unpredictable spikes but also control costs.Step 2: Evaluate billing options
Provisioned mode with auto scaling adjusts capacity automatically, balancing cost and flexibility better than fixed provisioned or pure on-demand.Step 3: Compare with other options
High fixed provisioned is costly; on-demand can be expensive at scale; manual limits reduce flexibility.Final Answer:
Use provisioned mode with low capacity and enable auto scaling -> Option BQuick Check:
Auto scaling balances cost and spikes well [OK]
- Choosing high fixed provisioned capacity unnecessarily
- Assuming on-demand always cheaper for spikes
- Trying to limit requests manually in on-demand mode
Ready to prove it?
Pass the test and this pattern moves unknown
