Lesson 2 of 7 Amazon RDS and Aurora

Keeping Databases Available with Multi-AZ Deployments

This lesson explains how Multi-AZ deployments keep a database available when an instance or an Availability Zone fails, by maintaining synchronous standby copies in other zones.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish Multi-AZ instance deployments from Multi-AZ DB clusters.
  • Explain how failover works.
  • Explain why Multi-AZ standbys do not scale reads.

Deployment options

RDS offers two Multi-AZ designs, which both protect against the loss of an instance or an Availability Zone. In a Multi-AZ instance deployment, RDS keeps a standby in another Availability Zone and copies every write to it synchronously, so no committed data is lost. The standby serves no reads. If the primary fails, RDS promotes the standby and moves the database's DNS name to it, so applications reconnect to the same endpoint, typically within one to two minutes.

A Multi-AZ DB cluster, available for MySQL and PostgreSQL, has a writer and two standbys in three Availability Zones. The standbys serve reads through a reader endpoint, and failover usually completes in under 35 seconds, so this design adds read capacity and faster recovery at a higher cost. Neither design replaces read replicas for scaling reads across Regions. The following table summarises the two options.

OptionReplicationServes reads?Failover
Multi-AZ instance deploymentSynchronous standby in another AZNoAutomatic through DNS, typically 1 to 2 minutes
Multi-AZ DB cluster (MySQL, PostgreSQL)One writer and two readable standbys in three AZsYes, through the reader endpointTypically under 35 seconds

The following diagram compares the two Multi-AZ designs.

The two RDS Multi-AZ designs. A Multi-AZ instance deployment keeps a synchronous standby in another zone that serves no reads, and fails over through DNS in typically one to two minutes. A Multi-AZ DB cluster, for MySQL and PostgreSQL, has a writer and two readable standbys in three zones, and fails over in usually under 35 seconds.
Neither design replaces read replicas for scaling reads in other Regions.
Sort into groups

Multi-AZ instance or DB cluster?

Exam skills 2.2.2 · 3.3.1

Decide which Multi-AZ design each statement describes.

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

How failover works

In a Multi-AZ deployment, RDS keeps a standby in another Availability Zone, updated by synchronous replication, so no committed data is lost when it takes over. RDS fails over automatically when the primary instance or its zone fails, and also during some maintenance and instance class changes.

During failover, RDS updates the database's DNS endpoint to point to the new primary, so applications reconnect without configuration changes; they should retry dropped connections and keep DNS caching short. Failover typically takes one to two minutes for a Multi-AZ instance. RDS Proxy keeps client connections open during failover and redirects them to the new primary, which shortens the disruption further.

Multi-AZ is not read scaling

A standby in a Multi-AZ instance deployment cannot serve traffic. To scale reads, use read replicas, or a Multi-AZ DB cluster whose standbys accept reads.

Scenario questions

Availability or performance?

Exam skills 3.3.1 · 2.2.2

Choose between Multi-AZ and read replicas.

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

Availability or performance?

An RDS for MySQL database has two problems: an AZ outage last year took the application offline for an hour, and reporting queries now slow down the online shop.

ProblemFeatureHow it helps
AZ outage causes downtimeMulti-AZ deploymentSynchronous standby in another AZ; automatic failover in about a minute or two
Reports slow the shopRead replicaReports run against an asynchronous copy, not the primary
Need to recover from a bad data change at 14:32Automated backupsPoint-in-time restore to a new instance
A copy of the data in another Region for DRCross-Region read replicaCan be promoted if the Region fails

A Multi-AZ standby cannot serve reads (in the classic single-standby deployment), and a read replica does not fail over automatically. Each feature solves its own problem, and the database uses both.

Check yourself

How do applications reach the database after a Multi-AZ failover?

Show answer

Through the same DNS endpoint, which RDS points at the new primary, so applications reconnect without configuration changes. They should retry dropped connections and avoid caching DNS for long.

Exam Tips

Remember for the exam

  • For high availability within a Region, use Multi-AZ.
  • A Multi-AZ instance standby cannot serve reads; use read replicas for read scaling.
  • For faster failover with readable standbys on MySQL or PostgreSQL, use a Multi-AZ DB cluster.
  • Applications reconnect after failover through the same DNS endpoint.