RDS pricing considerations in AWS - Time & Space 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.
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.
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.
Each new instance adds a fixed cost for storage and backup.
| Input Size (n) | Approx. Number of Instances |
|---|---|
| 10 | 10 instances |
| 100 | 100 instances |
| 1000 | 1000 instances |
Cost grows directly with the number of instances you create.
Time Complexity: O(n)
This means cost increases in a straight line as you add more RDS instances.
[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.
Understanding how costs grow with resource count helps you design cloud solutions that stay affordable as they scale.
What if we changed backup retention from 7 days to 14 days? How would the time complexity of cost growth change?