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?
Practice
Solution
Step 1: Understand RDS pricing components
RDS pricing depends on instance size, storage, backups, and deployment options, not on users or tables.Step 2: Identify the factor affecting hourly cost
The instance size determines the compute capacity and directly affects the hourly price.Final Answer:
The instance size (e.g., db.t3.medium vs db.m5.large) -> Option BQuick Check:
Instance size = hourly cost [OK]
- Confusing number of users with cost
- Thinking database engine version affects hourly price
- Assuming number of tables changes cost
Solution
Step 1: Review valid RDS storage types
AWS RDS supports SSD General Purpose (gp2/gp3), Provisioned IOPS SSD, and Magnetic (deprecated).Step 2: Identify the valid current option
SSD General Purpose (gp3) is a valid and recommended storage type for RDS.Final Answer:
SSD General Purpose (gp3) -> Option CQuick Check:
gp3 is valid RDS storage [OK]
- Selecting deprecated or unsupported storage types
- Confusing tape or NVMe with RDS storage
- Assuming Magnetic is still recommended
Solution
Step 1: Analyze cost impact of backup retention
Backup storage beyond allocated free backup size adds cost, but increasing retention from 7 to 35 days may add moderate cost.Step 2: Analyze cost impact of storage increase
Doubling storage from 100 GB to 200 GB doubles storage cost, which is a significant monthly cost increase.Step 3: Analyze instance type and engine changes
Changing to smaller instance reduces cost; engine change does not affect pricing directly.Final Answer:
Increasing storage from 100 GB to 200 GB -> Option DQuick Check:
Storage size increase = biggest cost rise [OK]
- Assuming backup retention always costs more
- Thinking smaller instance increases cost
- Believing engine type changes price
Solution
Step 1: Understand Multi-AZ pricing
Multi-AZ doubles instance cost because a standby instance runs in another zone.Step 2: Understand backup storage pricing
Automated backups must be enabled to incur backup storage charges; if disabled, no backup storage cost applies.Final Answer:
You will be charged for Multi-AZ but no backup storage cost -> Option AQuick Check:
Multi-AZ charges apply; backups disabled means no backup cost [OK]
- Assuming backup storage cost applies without backups enabled
- Thinking Multi-AZ is free
- Confusing manual snapshots with automated backups
Solution
Step 1: Identify cost and availability needs
Low latency and high availability require Multi-AZ deployment and sufficient instance size.Step 2: Evaluate storage and instance size
gp3 storage is cost-effective and performant; small instance reduces cost while Multi-AZ ensures availability.Step 3: Compare options
Use a small instance with Multi-AZ deployment and gp3 storage balances cost (small instance), availability (Multi-AZ), and performance (gp3 storage).Final Answer:
Use a small instance with Multi-AZ deployment and gp3 storage -> Option AQuick Check:
Small + Multi-AZ + gp3 = cost-effective high availability [OK]
- Choosing Magnetic storage which is slower and deprecated
- Ignoring Multi-AZ for high availability
- Picking large instance unnecessarily increasing cost
Ready to prove it?
Pass the test and this pattern moves unknown
