RDS: Multi-AZ, Read Replicas & Scaling
Multi-AZ Deployment
Multi-AZ maintains a synchronous standby replica in a different Availability Zone. Failover happens automatically in 60–120 seconds when AWS detects an issue. The standby is not readable — it exists only for HA.
Synchronous replication: every write is confirmed on standby before ACK to application
Automatic failover: DNS endpoint switches to standby — application just reconnects
Failover triggers: primary AZ outage, primary instance failure, manual failover, OS patching
RTO: typically 60–120 seconds; RPO: 0 (synchronous replication)
Multi-AZ does NOT improve read performance — use Read Replicas for that
# Enable Multi-AZ on existing instance
aws rds modify-db-instance \
--db-instance-identifier my-postgres \
--multi-az \
--apply-immediately # or --no-apply-immediately for next maintenance window
# Manually trigger failover (for testing)
aws rds reboot-db-instance \
--db-instance-identifier my-postgres \
--force-failoverMulti-AZ DB Cluster (newer option)
Multi-AZ DB Cluster uses 3 DB instances across 3 AZs with semi-synchronous replication. One writer, two readers. Readers ARE accessible for reads. Faster failover than classic Multi-AZ (~35 seconds). Available for PostgreSQL and MySQL.
Read Replicas
Read replicas use asynchronous replication. They are readable, reducing load on the primary. You can have up to 15 replicas (PostgreSQL). Promote a replica to a standalone instance in disaster scenarios.
# Create read replica (same region)
aws rds create-db-instance-read-replica \
--db-instance-identifier my-postgres-replica-1 \
--source-db-instance-identifier my-postgres \
--db-instance-class db.t3.medium
# Cross-region read replica
aws rds create-db-instance-read-replica \
--db-instance-identifier my-postgres-us \
--source-db-instance-identifier arn:aws:rds:eu-west-1:123456789012:db:my-postgres \
--db-instance-class db.t3.medium \
--region us-east-1
# Promote replica to standalone (for disaster recovery or migration)
aws rds promote-read-replica \
--db-instance-identifier my-postgres-replica-1
# Monitor replication lag
aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--metric-name ReplicaLag \
--dimensions Name=DBInstanceIdentifier,Value=my-postgres-replica-1 \
--start-time 2024-01-01T00:00:00Z \
--end-time 2024-01-01T01:00:00Z \
--period 60 \
--statistics AverageRDS Proxy
RDS Proxy sits between your application and RDS. It pools and reuses database connections, dramatically reducing connection overhead for Lambda functions and high-concurrency apps. Supports IAM auth and Secrets Manager.
Reduces connection overhead: Lambda can open thousands of concurrent "connections" — Proxy multiplexes them
Faster failover: Proxy maintains warm connections to standby, reduces failover impact on app
IAM database authentication: authenticate with IAM token instead of password
Automatic secrets rotation: works with Secrets Manager, no app restarts needed
# Create RDS Proxy
aws rds create-db-proxy \
--db-proxy-name my-postgres-proxy \
--engine-family POSTGRESQL \
--auth '[{"AuthScheme":"SECRETS","SecretArn":"arn:aws:secretsmanager:eu-west-1:123:secret:rds-creds","IAMAuth":"REQUIRED"}]' \
--role-arn arn:aws:iam::123456789012:role/rds-proxy-role \
--vpc-subnet-ids subnet-abc subnet-def \
--vpc-security-group-ids sg-proxy
# Application uses proxy endpoint instead of RDS endpoint
# proxy-endpoint: my-postgres-proxy.proxy-abc.eu-west-1.rds.amazonaws.comVertical Scaling
# Change instance class (requires brief downtime, use maintenance window)
aws rds modify-db-instance \
--db-instance-identifier my-postgres \
--db-instance-class db.m6g.large \
--apply-immediately # or schedule for maintenance windowBlue/Green Deployments
Blue/Green creates a staging environment (Green) with your changes (new engine version, parameter changes). Traffic switches instantly. Rollback is just switching back. Zero-downtime upgrades for minor versions; brief cutover for major.
# Create Blue/Green deployment
aws rds create-blue-green-deployment \
--blue-green-deployment-name my-postgres-upgrade \
--source arn:aws:rds:eu-west-1:123456789012:db:my-postgres \
--target-engine-version 16.1
# After testing, switch over
aws rds switchover-blue-green-deployment \
--blue-green-deployment-identifier bgd-abc123Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free