Sub topic 9
Highly available databases: RDS Multi-AZ and Aurora
This chapter assumes you know the earlier chapters on AZs, failure domains, and multi-AZ subnet layout. You should also be comfortable with the AWS CLI. The data tier is often the hardest single point of failure to remove, because it holds state.
RDS Multi-AZ instance deployment
In a Multi-AZ DB instance deployment, RDS runs a primary in one AZ and a standby in another. Storage is replicated synchronously, so a committed write exists in both AZs. The standby does not serve reads. It exists only for failover.
Your application connects to a DNS endpoint. On failure, RDS promotes the standby and repoints the endpoint's DNS name. Failover usually takes 60 to 120 seconds. Clients must reconnect, and they must not cache DNS results for long.
You need a DB subnet group with subnets in at least two AZs. To convert an existing instance:
aws rds modify-db-instance \
--db-instance-identifier mydb \
--multi-az \
--apply-immediatelyRDS takes a snapshot and builds the standby in the background. Expect some I/O impact while it does.
RDS Multi-AZ DB cluster
A Multi-AZ DB cluster (MySQL and PostgreSQL) has one writer and two readable standbys in three AZs. Replication is semisynchronous. Failover typically takes under 35 seconds, and the standbys can serve read traffic through a reader endpoint.
Aurora
Aurora separates compute from storage. The cluster volume keeps six copies of your data across three AZs, whatever the number of instances. You add Aurora Replicas, up to 15, in other AZs. A replica can serve reads and is also a failover target.
Aurora gives you these endpoints:
- The cluster endpoint always points to the writer.
- The reader endpoint load-balances across replicas.
If the writer fails, Aurora promotes the replica with the best promotion tier, usually in about 30 seconds. If the cluster has no replica, Aurora must create a new instance, which takes much longer. For availability, run at least one replica in a different AZ from the writer.
Choosing an option
| Option | Standby readable | Typical failover | Notes |
|---|---|---|---|
| RDS Multi-AZ instance | No | 60 to 120 s | Simplest, widest engine support |
| RDS Multi-AZ DB cluster | Yes | Under 35 s | MySQL and PostgreSQL only |
| Aurora with replicas | Yes | About 30 s | Storage already spans three AZs |
Measuring failover
Do not trust the numbers above for your own application. Force a failover and watch how your clients behave:
aws rds reboot-db-instance \
--db-instance-identifier mydb \
--force-failoverCommon errors
- Aurora has one instance and no replica, so there is no fast failover target.
- The application uses a resolved IP address or a long DNS cache, so it keeps hitting the old primary.
- Connection pools do not discard broken connections after failover.
- Read traffic is sent to the cluster endpoint, so it loads the writer.
Exercise
An Aurora cluster has one writer instance in AZ A and no replicas. The cluster volume spans three AZs. Does losing AZ A cause data loss, and is the database quickly available again?
Show answer
There is no data loss, because the cluster volume keeps copies in other AZs. Availability is slow to return, because Aurora must create a new instance rather than promote an existing one. Adding a replica in another AZ gives a fast failover target.