Stop 09 · Databases on AWSTopics · 2/11

RDS Multi-AZ Deployments

Part of the AWS Roadmap

In short

Servers fail, and sometimes a whole data centre has a bad day. If your only database lives there, your app is down too. High availability means a standby is already waiting to take over.

A Multi-AZ deployment keeps a synchronous standby copy of your database in another Availability Zone and fails over to it automatically if the primary has a problem. It is for availability, not for spreading read traffic.

The blob character in costume peeks out from behind a stage curtain, ready to go on.

Think of it like this

The understudy backstage

In the annual-day play, an understudy learns every line and waits in costume backstage. If the lead falls sick mid-show, the understudy walks on and the play continues. A Multi-AZ standby is that understudy for your database.

Watch it happen

A Multi-AZ failover

App
DB endpoint
Primary (AZ-a)
Standby (AZ-b)

INSERT order

1/6The app writes through the endpoint name, which points to the primary in zone A.

The big ideas

What you need to know

Synchronous standby

Multi-AZ keeps a standby in another zone, updated before each commit returns. It's for survival, not for reading.

Automatic failover

On failure or patching, the endpoint moves to the standby. Your connection string doesn't change.

Apps must reconnect

Connections drop during failover. Use retries with backoff and connection pools that recover cleanly.

Cross-region is different

Copies in another region are usually asynchronous, for disaster recovery. They can lag and may miss the last few seconds.

See it in code

Walk through the code

bash
1# Turn on Multi-AZ for an existing instance2aws rds modify-db-instance \3  --db-instance-identifier notes-db \4  --multi-az \5  --apply-immediately6 7# Practise a failover in a test environment8aws rds reboot-db-instance \9  --db-instance-identifier notes-db \10  --force-failover

1/2Add a standby in another zone. This costs roughly double the instance price.

Forcing a failover is the honest test of whether your app's retry logic really works. Do it in staging, not on a Friday in production.

Save yourself the pain

Common mistakes

Oops

Hard-coding the primary's IP address in the app.

Do this instead

Always connect via the endpoint name. After failover the IP changes, but the name follows the new primary.

Oops

Thinking Multi-AZ also protects against bad deletes.

Do this instead

The standby copies every change, including mistakes. You still need backups for that.

Your mission

Time a failover

~45 min

Quick check

Why is the Multi-AZ standby updated synchronously?

Go deeper

  1. 1Enable Multi-AZ on a test instance and note the cost difference in the Pricing Calculator.
  2. 2Trigger a reboot with failover and time how long the app is unavailable.
  3. 3Explain why the app should connect through the RDS endpoint name, never an IP.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge