Relational Databases with RDS and Aurora
Run managed PostgreSQL and MySQL on RDS and Aurora with Multi-AZ, read replicas, backups, parameter groups and secure connectivity.
Intermediate · about 6 hours · difficulty 3/5
Learn first: NAT Gateways, Security Groups and NACLs, EC2 Instances, AMIs and Pricing Options
Most applications need a relational database. Amazon RDS runs PostgreSQL, MySQL, MariaDB, Oracle and SQL Server for you: provisioning, patching, backups and failover. Azure SQL Database / Azure Database for PostgreSQL and Google Cloud SQL are the equivalents.
Key RDS features
- Multi-AZ: a synchronous standby in another AZ with automatic failover in a minute or two. This is for availability, not for scaling reads.
- Read replicas: asynchronous copies for read-heavy workloads or reporting, and can be cross-region.
- Automated backups with point-in-time restore (up to 35 days) plus manual snapshots.
- Parameter groups for engine settings and option groups for extra features.
- Storage autoscaling and gp3 storage.
Amazon Aurora
- AWS-built engine compatible with MySQL and PostgreSQL.
- Storage is shared across three AZs with six copies; replicas fail over faster.
- Aurora Serverless v2 scales capacity in small steps, good for spiky workloads.
- More expensive per hour than plain RDS, so use it when its features matter.
Connecting securely
- Place databases in private subnets with a security group that only allows the app tier.
- Store credentials in Secrets Manager with rotation, or use IAM database authentication.
- RDS Proxy pools connections, important for Lambda functions that open many short connections.
Pitfalls
- Making the database publicly accessible for convenience.
- Confusing Multi-AZ with read replicas in interviews.
- Leaving a test database running for a month.
You are ready to move on when you can launch a private RDS PostgreSQL instance, connect from an app instance, restore it to a point in time and explain Multi-AZ vs read replica.
Key concepts
- RDS engines
- Multi-AZ deployments
- Read replicas
- Automated backups and PITR
- Parameter groups
- Aurora and Aurora Serverless v2
- RDS Proxy
- IAM database authentication
- Database Migration Service
Mini project
Launch a free-tier eligible RDS PostgreSQL db.t3.micro or db.t4g.micro in a private subnet, connect from an instance via Session Manager, load a small table, then do a point-in-time restore to a new instance. Single-AZ only to stay in free tier, and delete both instances (skip the final snapshot) the same day.
Check yourself
Your read-heavy reporting queries slow down the main app. Would Multi-AZ help? What would?
Free resources
- Amazon RDS documentation (AWS)
- Amazon Aurora (AWS)
- Amazon RDS Proxy (AWS)