RDS — Managed Databases
PostgreSQL, MySQL, and Aurora on AWS — automated backups, Multi-AZ failover, and read replicas without the ops overhead
Skills taught: aws.rds, aws.rds-postgres, aws.multi-az, aws.read-replicas, aws.rds-snapshots, aws.parameter-groups
Why use RDS instead of running your own database?
Running a production PostgreSQL database properly requires: automated backups with point-in-time recovery, high availability with automatic failover, monitoring and alerting, OS and database engine patching, storage auto-scaling, and encryption at rest. Setting all this up manually takes weeks and requires deep database administration expertise. RDS gives you all of it in 10 minutes, managed by AWS.
RDS engines and when to choose each
PostgreSQL → Best default choice. Open source, most SQL features,
excellent JSON support (JSONB), full-text search.
Use: general-purpose relational data
MySQL → Widest legacy compatibility. Good for WordPress, PHP apps.
Use: apps that specifically require MySQL
Aurora PostgreSQL → AWS's proprietary engine, PostgreSQL-compatible
5x faster than standard PostgreSQL, auto-scaling storage
Higher cost but better performance + availability
Use: high-traffic production apps
Aurora MySQL → Like Aurora PostgreSQL but MySQL-compatible
MariaDB → MySQL fork, open source. Good MySQL alternative
Oracle / SQL Server → Enterprise licensing. Use only if you must
For a new project: start with RDS PostgreSQL (db.t4g.micro = $12/month)
Scale to Aurora PostgreSQL when you need the performance or HA features
Creating an RDS PostgreSQL instance
# Create a PostgreSQL RDS instance
aws rds create-db-instance \
--db-instance-identifier myapp-postgres-prod \
--db-instance-class db.t4g.micro \
--engine postgres \
--engine-version 16.3 \
--master-username dbadmin \
--master-user-password 'SecurePassword123!' \
--allocated-storage 20 \
--storage-type gp3 \
--storage-encrypted \
--backup-retention-period 7 \
--multi-az \
--publicly-accessible false \
--vpc-security-group-ids sg-xxxxxxxxxxxxxxxxx \
--db-subnet-group-name myapp-db-subnet-group
# Instance classes (2026 pricing in us-east-1):
# db.t4g.micro → 2 vCPU, 1GB RAM → $12/month (free tier: 750h/month)
# db.t4g.small → 2 vCPU, 2GB RAM → $25/month
# db.t4g.medium → 2 vCPU, 4GB RAM → $50/month
# db.r7g.large → 2 vCPU, 16GB RAM → $180/month (memory-optimized)
# Wait for it to be available (5-10 minutes)
aws rds wait db-instance-available --db-instance-identifier myapp-postgres-prod
# Get the endpoint
aws rds describe-db-instances \
--db-instance-identifier myapp-postgres-prod \
--query 'DBInstances[0].Endpoint.Address' \
--output text
# Output: myapp-postgres-prod.xxxxxx.ap-south-1.rds.amazonaws.com
# Connect via psql
psql -h myapp-postgres-prod.xxxxxx.ap-south-1.rds.amazonaws.com \
-U dbadmin -d postgres
Multi-AZ and Read Replicas
MULTI-AZ DEPLOYMENT (--multi-az flag):
Primary DB [AZ: us-east-1a] ←── All reads/writes
│ synchronous replication
Standby DB [AZ: us-east-1b] ←── Automatic failover target
- Failover is automatic (60-120 seconds) if primary fails
- DNS endpoint stays the same — app reconnects automatically
- Standby is NOT used for reads — it's a hot spare only
- Cost: 2x (you pay for both instances)
- Required for production: YES
READ REPLICAS (separate feature):
Primary DB → Replica 1 (same region)
→ Replica 2 (different region)
→ Replica 3 (different AZ)
- Asynchronous replication — slight lag (milliseconds to seconds)
- Replicas ARE readable — offload reporting queries here
- Can be promoted to primary in 1-2 minutes (manual)
- Up to 5 replicas per instance
- Cost: each replica charged at instance rate
- Use: scale read-heavy workloads (dashboards, reports)
Combine both: Multi-AZ primary + read replicas for full production HA
Backups and point-in-time recovery
# Automated backups (enabled by default, retention 1-35 days)
# --backup-retention-period 7 → keep 7 days of automated backups
# Point-in-time recovery: restore to any second in the retention window
# Create a manual snapshot (before risky migrations)
aws rds create-db-snapshot \
--db-instance-identifier myapp-postgres-prod \
--db-snapshot-identifier before-migration-2026-10-09
# List snapshots
aws rds describe-db-snapshots --db-instance-identifier myapp-postgres-prod
# Restore to a point in time (creates NEW instance from old data)
aws rds restore-db-instance-to-point-in-time \
--source-db-instance-identifier myapp-postgres-prod \
--target-db-instance-identifier myapp-postgres-restored \
--restore-time 2026-10-09T10:00:00Z
# Restore from snapshot
aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier myapp-postgres-restored \
--db-snapshot-identifier before-migration-2026-10-09
Tip: Never make your RDS instance publicly accessible. Set --publicly-accessible false. Your app should connect from within the same VPC using private IP addresses. If you need to access the database from your laptop for development, use an SSH tunnel via a bastion host or AWS Session Manager — never open port 5432 to the internet.
Frequently Asked Questions
Should I use RDS or manage my own PostgreSQL on EC2?
Use RDS for production unless you have a very specific reason not to. RDS handles backups, patches, failover, monitoring, and encryption. Self-managed on EC2 saves some cost but requires you to handle all of that yourself — and database administration is a full-time specialty. The cost difference is typically 20-30% — almost always worth it.