Skip to Content

Read replicas and Multi-AZ

Read replicas for read scaling, their network cost, Multi-AZ standbys for failover, Multi-AZ DB clusters, moving from Single-AZ to Multi-AZ, and RDS Custom.

Two different problems

RDS offers two kinds of extra copy of a database, and they solve different problems:

  • Read replicas solve too many reads. They are extra, read-only databases the application can query. They are about scaling.
  • Multi-AZ solves an AZ or instance failure. A standby copy waits in another AZ and takes over automatically. It is about availability.

Read replicas

Read replicas: the application writes to and reads from the primary instance; RDS copies changes asynchronously to read replicas, which serve reads only; replication to a replica in the same Region has no data transfer charge, while a replica in another Region is charged for transfer Read replicas: the application writes to and reads from the primary instance; RDS copies changes asynchronously to read replicas, which serve reads only; replication to a replica in the same Region has no data transfer charge, while a replica in another Region is charged for transfer

Write to the primary, read from the replicas.

A read replica is a read-only copy of a DB instance.

  1. The application sends writes (and any reads it wants) to the primary instance.
  2. RDS uses the engine's own replication to copy each change to the replicas asynchronously: the primary doesn't wait for them. So reads from a replica are eventually consistent; they may be a little behind.
  3. The application sends read-only queries (SELECT) to a replica's own endpoint. Replicas can't take INSERT, UPDATE or DELETE.

Key facts:

  • Up to 15 read replicas per source instance (for Oracle, AWS recommends keeping to 5).
  • A replica can be in the same AZ, another AZ or another Region.
  • Each replica has its own DNS endpoint. The application must be changed to send reads there; RDS doesn't split reads automatically.
  • A replica can be promoted to a standalone database. Replication stops and it accepts writes. Useful for disaster recovery, or for splitting a database.
  • A replica can itself be Multi-AZ, for a replica that survives an AZ failure.
  • Replicas are billed as normal DB instances.

Use case: reporting without slowing production

A production database is busy with the shop's normal traffic. The business wants a reporting app that runs heavy analytics queries. Running them on the primary would slow the shop down. Instead, a read replica is created and the reporting app points at it. The production app is unaffected.

Network cost

In AWS, data moving from one AZ to another usually costs money. RDS read replicas are an exception: replication to a replica in the same Region has no data transfer charge, even in another AZ. Replication to a replica in another Region is charged.

Multi-AZ

Multi-AZ: applications connect to one DNS endpoint that points to the primary instance in Availability Zone a; RDS replicates synchronously to a standby in Availability Zone b, which takes no traffic; on failover the DNS endpoint points to the standby Multi-AZ: applications connect to one DNS endpoint that points to the primary instance in Availability Zone a; RDS replicates synchronously to a standby in Availability Zone b, which takes no traffic; on failover the DNS endpoint points to the standby

A standby in another AZ, one name for both.

A Multi-AZ deployment keeps a standby instance in a different AZ.

  1. The application connects to one DNS endpoint.
  2. Every write to the primary is copied synchronously to the standby: a write only succeeds once both have it. No data is lost on failover.
  3. If the primary fails (loss of the AZ, the network, the instance or its storage), RDS fails over automatically: the DNS name now points to the standby, which becomes the new primary. It usually takes a minute or two.
  4. The application needs no change; it just reconnects to the same name.

The standby serves no traffic: it can't be read from. Multi-AZ is for availability, not for scaling. It also makes backups and patching smoother, because RDS can work on the standby first.

Exam tip

Read replicas can also be set up as Multi-AZ. And in a disaster a read replica in another Region can be promoted, which Multi-AZ (one Region only) can't provide.

Multi-AZ DB clusters

There's a newer option for MySQL and PostgreSQL: a Multi-AZ DB cluster. It has a writer and two readable standbys in three AZs. Replication is semisynchronous, failover is faster than with one standby, and the two readers can serve read traffic. The classic Multi-AZ with one hidden standby is called a Multi-AZ DB instance deployment.

Updated since the slides

The slides describe only the one-standby Multi-AZ, where the standby can't be read. AWS has since added Multi-AZ DB clusters (MySQL and PostgreSQL) with two readable standbys. On the exam, "Multi-AZ" with "the standby can't serve reads" means the classic deployment.

Going from Single-AZ to Multi-AZ

Turning on Multi-AZ is a zero-downtime change: click Modify and choose Multi-AZ. Behind the scenes:

  1. RDS takes a snapshot of the primary.
  2. It restores that snapshot as a new standby in another AZ.
  3. It sets up synchronous replication between the two, and the standby catches up.

Read replicas vs Multi-AZ

Read replicaMulti-AZ
ForScaling readsFailover
CopyingAsyncSync
ReadsYesNo

RDS Custom

Normal RDS gives no access to the operating system. RDS Custom does, for Oracle and Microsoft SQL Server only.

  • AWS still automates setup, backups and scaling, but it also gives full admin access to the database and its EC2 instance.
  • Settings can be changed, patches installed, and features that need the OS turned on. Connections use SSH or SSM Session Manager.
  • Before customising, pause the automation (the slides call it de-activating automation mode) so RDS doesn't undo or fight the changes, and take a snapshot first.

So: RDS = AWS manages the database and the OS. RDS Custom = the customer gets the OS and database too, with AWS still doing the routine work.

Real-world examples

  • A news site gets 50 times more reads than writes. Three read replicas take the read traffic, and the primary handles the writes.
  • A bank's core database runs Multi-AZ. When an AZ has a power problem, RDS fails over in about a minute and the app reconnects by itself.
  • A company with a legacy SQL Server app needs a third-party agent installed on the database server. RDS Custom for SQL Server allows it.

Exam tips

  • "Read-heavy", "reporting queries slow down production", "scale reads" → read replicas.
  • "High availability", "survive an AZ failure", "automatic failover", "no data loss" → Multi-AZ.
  • "Replica lag", "reads may be stale" → asynchronous read replicas.
  • "Disaster recovery to another Region" → cross-Region read replica (promote it).
  • "Reduce cross-AZ replication cost" → RDS replicas in the same Region are free to replicate to.
  • "Make an existing database Multi-AZ with no downtime" → modify it.

Common traps

  • "Multi-AZ standby to offload reads." The classic standby takes no traffic; use read replicas.
  • "Read replicas for automatic failover." Promotion is manual; Multi-AZ fails over automatically.
  • "Change the application's connection string after a Multi-AZ failover." Not needed: the DNS name stays the same.
  • "Read replicas need no application change." The app must send reads to the replica endpoints.

Hands-on lab: add a read replica

Goal: create a read replica of a small database and see that it refuses writes.

Costs money

Two db.t4g.micro instances (primary and replica) with 20 GiB each: about $0.04 an hour. Delete both the same day. Any Region works.

Before you start: create saa-db as in the RDS lab, connected to saa-web.

Create the replica

Select saa-db → Actions → Create read replica. Identifier saa-db-replica, instance class db.t4g.micro, a different AZ from the primary, Public access No. Create. It takes about 10 minutes.

Allow your instance to reach it

The replica uses the primary's security groups, so saa-web can already reach it. Copy the replica's endpoint: it differs from the primary's.

Write to the primary, read from the replica

From saa-web:

psql -h <primary-endpoint> -U postgres -c "create table t(x int); insert into t values (42);"
psql -h <replica-endpoint> -U postgres -c "select * from t;"
psql -h <replica-endpoint> -U postgres -c "insert into t values (1);"

The select on the replica returns 42. The insert fails with cannot execute INSERT in a read-only transaction.

Expected result: data written to the primary shows up on the replica within seconds, and the replica refuses writes.

Clean up: delete saa-db-replica, then saa-db (no final snapshot, no retained backups), then the two rds-ec2-* / ec2-rds-* security groups.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt