Lesson 1 of 3 Resilient Data Stores

Building Highly Available Relational Databases with Amazon RDS and Aurora

Relational databases are often the hardest part of a workload to make resilient, because they hold state and usually accept writes in only one place. This lesson explains the high availability options of Amazon RDS and Amazon Aurora, read replicas, cross-Region designs with Aurora Global Database, storage auto scaling, backups and how failover is tested.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish between RDS Multi-AZ DB instance deployments, Multi-AZ DB cluster deployments and read replicas.
  • Explain the Aurora storage architecture, replicas, failover priority tiers and endpoints.
  • Explain Aurora Global Database switchover and failover and RDS cross-Region read replica promotion.
  • Describe RDS storage auto scaling, automated backups, point-in-time recovery and methods for testing failover.

Amazon RDS Multi-AZ Deployments

Amazon RDS runs managed MySQL, PostgreSQL, MariaDB, Oracle, SQL Server and Db2 databases. It offers two forms of Multi-AZ high availability.

Multi-AZ DB instance deployment

RDS maintains a synchronous standby replica in another AZ. Every write is committed to both before it is acknowledged, so no committed data is lost in a failover. The standby cannot serve reads. If the primary fails, its AZ fails, its storage fails or it is rebooted with failover, RDS promotes the standby and updates the DNS name of the database endpoint to point to it; failover typically completes in one to two minutes. Applications must reconnect and should not cache the endpoint's IP address. Converting a single-AZ instance to Multi-AZ is an online operation.

Multi-AZ DB cluster deployment

Available for MySQL and PostgreSQL, a Multi-AZ DB cluster has a writer and two readable standbys in three AZs, using semi-synchronous replication: a write is acknowledged when at least one standby has received it. The standbys serve read traffic through a reader endpoint, and failover is faster, typically under 35 seconds.

Read replicas

Read replicas use asynchronous replication to offload read traffic. They can be in the same AZ, another AZ or another Region, and they can themselves be Multi-AZ. A read replica is not a high availability mechanism by itself, because it may lag and failover is not automatic; instead, a replica can be promoted to a standalone database, which is how cross-Region disaster recovery works for RDS. Promotion breaks replication and takes several minutes.

Multi-AZ instance
ReplicationSynchronous
Serves readsNo
Automatic failoverYes, 1 to 2 minutes
Cross-RegionNo
Choose when High availability for any RDS engine.
Multi-AZ cluster
ReplicationSemi-synchronous
Serves readsYes, two standbys
Automatic failoverYes, under 35 seconds typically
Cross-RegionNo
Choose when Faster failover and read scaling for MySQL or PostgreSQL.
Read replica
ReplicationAsynchronous
Serves readsYes
Automatic failoverNo; manual promotion
Cross-RegionYes
Choose when Read scaling and cross-Region DR.
Sort into groups

Which RDS option?

Exam skills 3.1.3 · 3.3.1

Tell apart RDS Multi-AZ instance, Multi-AZ cluster and read replicas.

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

Amazon Aurora Architecture

Amazon Aurora is a MySQL- and PostgreSQL-compatible database with a distributed storage layer. Data is stored as six copies across three AZs in a shared cluster volume that grows automatically up to 128 TiB. Writes need four of six copies and reads three of six, so Aurora tolerates the loss of an entire AZ plus one more copy without losing data, and storage repairs itself continuously.

A cluster has one writer instance and up to 15 Aurora Replicas that read from the same shared volume, so replica lag is typically under 100 milliseconds and replicas need no copy of the data. If the writer fails, Aurora promotes a replica, usually within about 30 seconds; if there are no replicas, Aurora creates a new writer, which takes longer. Each replica has a failover priority tier from 0 to 15, and Aurora promotes the replica with the highest priority (lowest number), choosing the largest if several share the tier, which lets architects ensure that a full-sized replica is promoted rather than a small reporting replica.

Applications connect through endpoints: the cluster (writer) endpoint always points to the current writer, the reader endpoint load-balances connections across replicas, custom endpoints group specific instances, for example for analytics, and instance endpoints address one instance. Using the cluster and reader endpoints means applications follow failovers automatically. Aurora Auto Scaling adds and removes replicas based on a target metric such as average CPU utilisation or connections, and Aurora Serverless v2 scales instance capacity in fine-grained increments, which suits variable workloads.

Cross-Region Designs

Aurora Global Database replicates a primary cluster to secondary clusters in other Regions using dedicated storage-level replication, with typical lag under one second, which gives an RPO of about one second for a Regional outage. Secondary clusters serve low-latency reads locally, and write forwarding can pass writes from a secondary to the primary. Two operations move the primary role. A switchover (planned) is used for maintenance or Region rotation: Aurora waits for the secondary to catch up, so no data is lost. A failover (unplanned) is used when the primary Region is impaired: Aurora promotes a secondary immediately, accepting the loss of data not yet replicated, and the old primary rejoins as a secondary when it recovers. A global writer endpoint lets applications follow the primary role across Regions.

For RDS engines, cross-Region read replicas provide the equivalent: the replica in the recovery Region is promoted during a disaster, and the application's connection configuration is switched, often through a Route 53 record. RTO is longer, because promotion takes minutes and is manual or scripted. Automated backups can also be replicated to another Region for backup-and-restore recovery.

Storage Auto Scaling, Backups and Point-in-Time Recovery

Running out of storage stops a database. RDS storage auto scaling increases allocated storage automatically when free space is low. It scales when free storage is below 10% of allocated storage, the low-storage condition has lasted at least five minutes, and at least six hours have passed since the last storage modification (or storage optimisation has completed). Each increase is the larger of 10 GiB, 10% of current storage or the predicted growth for the next seven hours, up to a maximum storage threshold that the administrator sets to control cost. Storage can only grow, never shrink. Aurora needs no storage scaling because its volume grows automatically.

10%

Free storage below which RDS storage auto scaling acts

5minutes

Minimum duration of the low-storage condition

6hours

Minimum interval between storage modifications

35days

Maximum automated backup retention

Automated backups take a daily snapshot and capture transaction logs, allowing point-in-time recovery to any second within the retention period, up to 35 days, typically to within five minutes of the current time. Restores always create a new instance or cluster, so applications must be pointed to it. Manual snapshots are kept until deleted and can be copied across Regions and shared across accounts (encrypted snapshots require sharing the KMS key). Aurora also offers backtrack for MySQL-compatible clusters, which rewinds the cluster in place to a previous time without a restore, and fast cloning for test copies.

RDS Blue/Green Deployments reduce the risk of database changes such as major version upgrades: RDS creates a synchronised green copy, the change is applied and tested on it, and a switchover promotes it, typically in under a minute, with guardrails that block the switchover if replication is not healthy.

Testing Failover

A failover mechanism that has never been exercised cannot be trusted. Testing methods are listed below.

  • RDS Multi-AZ: reboot the instance with the failover option (reboot-db-instance --force-failover), which forces promotion of the standby.
  • Aurora: failover-db-cluster, optionally naming the target replica, or AWS FIS actions that fail over a cluster.
  • Aurora Global Database: a planned switchover to the secondary Region, followed by a switchover back, exercises the cross-Region path without data loss.
  • RDS cross-Region replica: promote a replica in a test copy of the environment, because promotion is irreversible.

During tests, measure the time until the application recovers, not only the database event, because DNS caching, connection pools and retry logic often dominate the real RTO. Amazon RDS Proxy keeps client connections open and routes them to the new writer, reducing application-visible failover time. RDS publishes events such as failover started and completed to EventBridge, which can drive notifications and runbooks.

Match the pairs

Test the failover

Exam skills 3.3.1

Match each database with how its failover is tested.

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

Meeting Database Objectives

An order database on RDS for PostgreSQL, single-AZ, must meet an RPO of zero and an RTO of two minutes for AZ failures, an RPO of one second and an RTO of 10 minutes for Regional failures, and must never run out of storage.

Single-AZ RDS meets none of these. Migrating to Aurora PostgreSQL with two replicas in different AZs at failover tier 0 gives zero data loss and failover in about 30 seconds within the Region. Adding the cluster to an Aurora Global Database with a secondary cluster in the recovery Region gives about one second of RPO, and a managed failover with an application connected through the global writer endpoint meets the 10-minute RTO. Aurora storage grows automatically. The team tests AZ failover monthly with failover-db-cluster and Regional recovery quarterly with a switchover.

Check yourself

A team plans Regional maintenance and wants to move the primary of an Aurora Global Database to another Region without losing any data. Which operation should it use?

Show answer

A switchover (planned). It waits for the secondary to synchronise before changing roles. An unplanned failover promotes immediately and can lose data that had not yet replicated.

Exam Tips

Remember for the exam

  • RDS Multi-AZ instance: synchronous standby, no reads, DNS-based failover in 1 to 2 minutes; Multi-AZ cluster: two readable standbys, failover typically under 35 seconds.
  • Read replicas are asynchronous and need manual promotion; they provide read scaling and cross-Region DR.
  • Aurora keeps six copies across three AZs; up to 15 replicas with failover priority tiers; use the cluster and reader endpoints.
  • Aurora Global Database: about one second RPO; switchover for planned moves without data loss, failover for outages.
  • RDS storage auto scaling acts below 10% free for 5 minutes, at most every 6 hours, up to the maximum storage threshold.
  • Test failover with reboot --force-failover, failover-db-cluster or AWS FIS; RDS Proxy shortens application-visible failover.