AWS Certified CloudOps Engineer – Associate
RDS Multi-AZ failover: DB instance vs DB cluster
The Amazon RDS User Guide says a Multi-AZ DB instance deployment keeps a synchronous standby in another Availability Zone and switches to it automatically, typically in 60 to 120 seconds. Failover changes the DNS record of the DB instance, so clients must reconnect. A Multi-AZ DB cluster instead has one writer and two readable instances.
What is a Multi-AZ DB instance deployment?
RDS provisions and maintains a standby replica in a different Availability Zone and replicates to it synchronously. The standby gives failover support only. It cannot serve read traffic, and AWS says the option is not a scaling solution for read-only work.
You can convert an existing DB instance by modifying it and choosing the Multi-AZ option. You do not have to create a new instance.
Because replication is synchronous, a Multi-AZ DB instance deployment can have higher write and commit latency than a Single-AZ deployment.
What happens during a failover?
RDS fails over without administrator action when the primary host is unhealthy or unreachable, when its storage fails, during an operating system patch in the maintenance window, after some instance modifications, or when you reboot the instance and choose reboot with failover. Failover typically takes 60 to 120 seconds; large transactions or a long recovery can extend it.
The failover changes the DNS record of the DB instance to point to the standby. Existing connections have to be re-established.
A Java virtual machine caches DNS lookups. On some configurations the default never refreshes an entry until the JVM restarts, so the application keeps using the old address. AWS recommends a JVM TTL of no more than 60 seconds, set through the networkaddress.cache.ttl property.
Do not use the Availability Zone shown in the console or DescribeDBInstances to confirm a failover, because it can take several minutes to update. The Multi-AZ instance failover completed event is the authoritative signal.
How is a Multi-AZ DB cluster different?
A Multi-AZ DB cluster has a writer DB instance and two reader DB instances in three Availability Zones in one Region. The readers are automatic failover targets and also serve read traffic.
Replication is semisynchronous: a change commits once at least one reader acknowledges it. AWS states that Multi-AZ DB clusters typically have lower write latency than Multi-AZ DB instance deployments.
Multi-AZ DB clusters are supported only on certain DB instance classes: db.c6gd, db.m5d, db.m6gd, db.m6id, db.m6idn, db.m8gd, db.r5d, db.r6gd, db.r6id, db.r6idn, db.r8gd and db.x2iedn. They are not the same as Aurora DB clusters.
Where the exam catches people
- Sending reporting queries to the standby of a Multi-AZ DB instance deployment: that standby cannot serve read traffic.
- Believing the endpoint changes after failover: the DNS record is repointed, the name stays the same, and clients must reconnect.
- Blaming RDS when a Java application fails after failover: a JVM that caches DNS without refreshing keeps the old address until it restarts.
- Believing you must rebuild a Single-AZ instance to add a standby: modifying the instance and choosing Multi-AZ converts it.
- Choosing a Multi-AZ DB instance deployment to cut commit latency: synchronous replication can raise it; a Multi-AZ DB cluster typically has lower write latency.