RDS & Aurora — Managed Relational Databases
Managed SQL on AWS — what RDS manages for you, engines, Multi-AZ deployments vs read replicas, backups and point-in-time recovery, Aurora's distributed storage architecture, Aurora replicas, Global Database and Serverless v2, Aurora DSQL, RDS Proxy, parameter groups, security, monitoring and scaling strategies.
Running a relational database yourself means installing it, patching it, configuring replication and failover, taking and testing backups, and monitoring disks at 3 a.m. Amazon RDS does most of that for PostgreSQL, MySQL, MariaDB, Oracle, SQL Server and Db2. Aurora is AWS's re-engineered, cloud-native version of MySQL and PostgreSQL. You still own schema design, queries and indexes (SQL advanced, Indexing).
What RDS manages
| AWS does | You do |
|---|---|
| Provisioning, OS and engine patching (in maintenance windows) | Schema, queries, indexes |
| Automated backups and point-in-time recovery | Choosing instance size and storage |
| Multi-AZ replication and automatic failover | Connection management in your app |
| Storage autoscaling | Security groups, IAM, encryption choices |
| Monitoring metrics | Tuning parameters, reviewing slow queries |
You can't SSH into the host or install arbitrary extensions (only supported ones). RDS Custom exists for Oracle and SQL Server when you need OS access.
Multi-AZ vs read replicas
The most important distinction — and a classic interview question:
| Multi-AZ (standby) | Read replica | |
|---|---|---|
| Purpose | High availability | Read scaling (and DR if cross-region) |
| Replication | Synchronous — no committed data lost on failover | Asynchronous — replica lag |
| Serves traffic? | No (classic Multi-AZ); Multi-AZ cluster standbys can serve reads | Yes, reads |
| Failover | Automatic, typically 1–2 minutes; same DNS endpoint | Manual promotion |
| Location | Another AZ, same region | Same or another region |
Your app connects to a DNS endpoint, not an IP. On failover RDS flips the DNS record to the standby — so set low DNS TTLs in your client and make it reconnect and retry (Replication).
Replica lag means reads from replicas can be stale: read your own writes from the primary, or route by consistency need (Consistency models).
Backups and recovery
- Automated backups: daily snapshot plus transaction logs, retained 1–35 days, enabling point-in-time recovery to any second in the window. Restores create a new instance with a new endpoint.
- Manual snapshots: kept until you delete them; copy across regions and accounts.
- AWS Backup for central policies across services.
- Test restores regularly — a backup you've never restored is a hope, not a plan.
Aurora
Aurora separates compute from a purpose-built distributed storage layer:
- The writer sends only redo log records to storage; storage nodes apply them. Six copies across three AZs; writes need 4 of 6 acknowledgements and reads 3 of 6, so it tolerates losing a whole AZ plus one more node for reads (Consensus).
- Storage grows automatically in 10 GB segments; no provisioning.
- Up to 15 Aurora replicas share the same storage, so replica lag is typically milliseconds, and any replica can be promoted on failover in about 30 seconds or less.
- Endpoints: a cluster (writer) endpoint, a reader endpoint load-balancing across replicas, and custom endpoints.
- Fast cloning (copy-on-write) creates a test copy of a large database in minutes; backtrack (MySQL) rewinds in place.
Aurora variants
| Feature | What it gives |
|---|---|
| Aurora Serverless v2 | Capacity scales in fine-grained increments (ACUs) in seconds, down to zero when idle (0 ACU with auto-pause) — for variable or dev workloads |
| Global Database | Storage-level replication to up to several secondary regions with typically under a second of lag; promote a region for disaster recovery |
| I/O-Optimized | Predictable pricing with no per-I/O charges, for I/O-heavy workloads |
| Aurora DSQL | A separate serverless, distributed PostgreSQL-compatible database with active-active multi-region writes and optimistic concurrency |
RDS vs Aurora: Aurora usually wins on availability, failover speed and replica scaling; standard RDS can be cheaper for small or steady databases and supports more engines.
Connections and RDS Proxy
Relational databases handle a limited number of connections, each costing memory. Serverless and highly scaled apps open too many.
RDS Proxy pools and multiplexes connections, absorbs bursts (Lambda scale-outs), keeps connections open across failovers (reducing failover impact), and supports IAM authentication. Equivalent self-managed options are PgBouncer and ProxySQL. Watch for connection pinning (session state like prepared statements or temporary tables can stop multiplexing).
Configuration and security
- Parameter groups hold engine settings (
max_connections,work_mem); option groups add features for some engines. - Place databases in private subnets (a DB subnet group spanning AZs) with a security group allowing only the app's security group (VPC).
- Encryption at rest with KMS must be chosen at creation (encrypt an existing database by snapshot → encrypted copy → restore).
- TLS in transit; enforce it with parameters like
rds.force_ssl. - Credentials in Secrets Manager with automatic rotation, or IAM database authentication with short-lived tokens.
Monitoring and scaling
- CloudWatch metrics: CPU, freeable memory, connections, read/write IOPS and latency, replica lag, disk queue depth.
- Performance Insights / Database Insights: database load broken down by wait events and top SQL — the fastest way to find the query causing trouble.
- Enhanced Monitoring: OS-level metrics.
Scaling path, roughly in order: fix queries and indexes → add read replicas and caching (Caching) → scale the instance up → partition or shard by tenant or key (Database scaling) → consider DynamoDB or Aurora DSQL for workloads that fit.
QWhat's the difference between Multi-AZ and read replicas in RDS?easy
Multi-AZ keeps a synchronously replicated standby in another availability zone for high availability: if the primary fails, RDS automatically fails over and updates the DNS endpoint, with no committed data lost. In the classic configuration the standby serves no traffic. Read replicas use asynchronous replication to offload read traffic and can live in other regions; they may lag behind, and promotion to primary is manual. They solve different problems and are often used together.
QWhy is Aurora's failover faster and its replica lag lower than standard RDS?hard
Aurora replicas don't replay a separate copy of the data; they share the same distributed cluster volume as the writer, which is stored as six copies across three AZs. The writer ships redo log records to the storage layer and replicas only need to update their in-memory caches, so lag is usually milliseconds. On failover, a replica already attached to the up-to-date storage is promoted, typically within about 30 seconds, without copying data or waiting for logs to replay.
QHundreds of Lambda functions are exhausting database connections. How do you fix it?medium
Put RDS Proxy between Lambda and the database so many function instances share a small pool of database connections. Cap the function's concurrency with reserved concurrency, or put a queue in front to smooth bursts. Make sure functions reuse connections across invocations by creating them outside the handler, and check for connection pinning in the proxy metrics. For very high scale, consider caching or a database designed for massive connection counts like DynamoDB.
- RDS manages provisioning, patching, backups, failover and storage scaling; you own schema, queries and access.
- Multi-AZ is synchronous replication for availability; read replicas are asynchronous copies for read scaling and DR.
- Automated backups give point-in-time recovery within the retention window; restores create new instances.
- Aurora's shared six-copy storage across three AZs gives fast failover, up to 15 low-lag replicas, cloning and Global Database.
- Use RDS Proxy to pool connections, especially from Lambda.
- Keep databases private, encrypted, TLS-only and with rotated or IAM-based credentials; diagnose with Performance Insights.