Lesson 4 of 5 Amazon RDS and Amazon Aurora

Understanding Multi-AZ Failover

This lesson explains how each Multi-AZ configuration fails over and what it does and does not provide, the basis of high availability for relational databases.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe Multi-AZ DB instance failover.
  • Describe Multi-AZ DB cluster and Aurora failover.
  • Distinguish Multi-AZ from read replicas.
  • Fix applications that do not recover after failover.

Multi-AZ DB instance

A Multi-AZ DB instance deployment keeps a standby in a different AZ with synchronous storage replication. The standby cannot serve reads. RDS fails over automatically when the primary instance, its storage, network or AZ fails, when the instance class is modified, during OS patching, or when you reboot with failover. The DNS name of the endpoint is updated to point to the standby, typically within 60 to 120 seconds, so applications must reconnect and should not cache DNS for long. Backups are taken from the standby, avoiding I/O suspension on the primary.

The following diagram shows a failover and why clients must reconnect by the endpoint name.

A Multi-AZ DB instance failover and why a client that caches the address does not recover. RDS promotes the standby and points the endpoint's DNS name at it, typically within 60 to 120 seconds. Applications that reconnect by name recover; an application that connects by IP address, or whose runtime caches DNS indefinitely, keeps trying the old primary.
The endpoint is illustrative. Any client that caches the old address waits until the cache expires, or forever.

Multi-AZ DB cluster and Aurora

A Multi-AZ DB cluster deployment (MySQL and PostgreSQL) has a writer and two readable standbys in three AZs, with semi-synchronous replication. Failover is typically under 35 seconds, and the reader endpoint serves read traffic from the standbys. Aurora stores six copies of data across three AZs regardless of instance count; with at least one Aurora Replica in another AZ, failover promotes a replica, usually in under 30 seconds. An Aurora cluster with only a writer recreates the instance after failure, which takes longer. The following table compares the options.

OptionStandbysReadable standbyTypical failover
Single-AZ instanceNone-Restore or wait for instance recovery
Multi-AZ DB instance1, synchronousNo60-120 seconds
Multi-AZ DB cluster2, semi-synchronousYesUnder 35 seconds
Aurora with replicas in other AZsUp to 15 replicas on shared storageYesUnder 30 seconds

60–120s

Typical Multi-AZ DB instance failover

< 35s

Typical Multi-AZ DB cluster failover

< 30s

Typical Aurora failover to a replica

True or false

Aurora and Multi-AZ clusters

Exam skills 2.2.2

Check facts about Multi-AZ DB clusters and Aurora.

Log in to try this activity Interactive activities are free with an account.

Multi-AZ compared with read replicas

Multi-AZ is for availability; read replicas are for read scaling (and, cross-Region, for DR). A Multi-AZ standby instance does not help with read load, and a read replica does not fail over automatically for RDS (it must be promoted). A design that needs both uses Multi-AZ plus replicas, or Aurora, where replicas do both jobs. Testing failover with aws rds reboot-db-instance --force-failover confirms that applications reconnect correctly.

Sort into groups

Multi-AZ or read replica?

Exam skills 2.2.2 · 2.1.3

Decide which feature each statement describes.

Log in to try this activity Interactive activities are free with an account.
Worked example

An application that does not recover after failover

After a Multi-AZ failover during an AZ issue, one Java application keeps failing for 20 minutes while others recover in two minutes. The failing application had connected to the database by IP address resolved at start-up and its JVM caches DNS indefinitely. The fix is to connect with the RDS endpoint name and set the JVM DNS cache TTL to 60 seconds or less (networkaddress.cache.ttl). Introducing RDS Proxy would further hide the failover from the application.

Check yourself

Can the standby of a Multi-AZ DB instance serve reads?

Show answer

No. A Multi-AZ DB cluster has two readable standbys instead.

Exam Tips

Remember for the exam

  • Multi-AZ DB instance: synchronous standby, not readable, failover by DNS in 1-2 minutes.
  • Multi-AZ DB cluster: two readable standbys, failover under 35 seconds.
  • Aurora fails over to a replica in under 30 seconds; keep replicas in other AZs.
  • Multi-AZ is for availability, read replicas for read scaling.
  • Applications must use the endpoint name and short DNS caching.