0
0
DynamoDBquery~5 mins

On-demand vs provisioned cost comparison in DynamoDB - Performance Comparison

Choose your learning style9 modes available
Time Complexity: On-demand vs provisioned cost comparison
O(n)
Understanding Time Complexity

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.

Scenario Under Consideration

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.

Identify Repeating Operations

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.
How Execution Grows With Input

Costs grow differently depending on mode and request volume.

Request Volume (n)On-demand CostProvisioned Cost
10Low (pay per request)Fixed (capacity units reserved)
100Moderate (more requests, more cost)Fixed (same reserved units)
1000High (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.

Final Time Complexity

Time Complexity: O(n) for on-demand mode cost growth

This means cost grows directly with the number of requests you make.

Common Mistake

[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.

Interview Connect

Understanding how costs scale with usage helps you design efficient and cost-effective DynamoDB solutions.

Self-Check

What if you switch from on-demand to provisioned mode but your request volume suddenly doubles? How would the cost behavior change?