0
0
AWScloud~5 mins

RDS pricing considerations in AWS - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: RDS pricing considerations
O(n)
Understanding Time Complexity

When using Amazon RDS, it's important to understand how costs grow as you add more resources or use more features.

We want to know how the number of resources or operations affects the total price.

Scenario Under Consideration

Analyze the cost growth when creating multiple RDS instances with backups and storage.


for i in range(n):
    aws rds create-db-instance \
      --db-instance-identifier db-instance-"$i" \
      --allocated-storage 20 \
      --backup-retention-period 7 \
      --db-instance-class db.t3.medium
    

This sequence creates n RDS instances, each with storage and backup enabled.

Identify Repeating Operations

Look at what repeats as n grows.

  • Primary operation: Creating an RDS instance with storage and backup.
  • How many times: Once per instance, so n times.
How Execution Grows With Input

Each new instance adds a fixed cost for storage and backup.

Input Size (n)Approx. Number of Instances
1010 instances
100100 instances
10001000 instances

Cost grows directly with the number of instances you create.

Final Time Complexity

Time Complexity: O(n)

This means cost increases in a straight line as you add more RDS instances.

Common Mistake

[X] Wrong: "Adding more instances won't increase cost much because backups are shared."

[OK] Correct: Each instance has its own storage and backup costs, so costs add up with each new instance.

Interview Connect

Understanding how costs grow with resource count helps you design cloud solutions that stay affordable as they scale.

Self-Check

What if we changed backup retention from 7 days to 14 days? How would the time complexity of cost growth change?