Skip to content

Lesson 20 of 38Running in production

Multi-Region and Disaster Recovery

Plan for losing a whole region: RPO and RTO, the four DR strategies, backups you have actually restored, cross-region data, failover routing, and cells.

13 min read0/4 questions

Somebody on the leadership team reads about a cloud region going down for half a day and asks the obvious question: "What happens to us if that happens to our region?" The honest answer at most companies is "we are not sure". Maybe there are backups. Maybe nobody has restored one this year. Maybe the app runs in three availability zones but the login service, the secrets store, and the CI pipeline all live in one region. Disaster recovery is the discipline of turning that shrug into numbers, a plan, and a drill you have actually run. It is also a favourite senior interview topic, because it forces you to talk about cost, consistency, and failure honestly.

Zones, regions, and what you are protecting against

Cloud providers split each region (a geographic area such as us-east-1 or eu-west-2) into several availability zones: separate data centres with independent power and networking, a few milliseconds apart. Running across three zones protects you from the most common big failures: a lost data centre, a power event, a bad rack. For most services, multi-AZ with good backups is the right answer, and synchronous replication between zones is cheap because the zones are close.

A region-wide failure is rarer but real: a control-plane bug, a bad config pushed across the region, a DNS problem in a core service. Protecting against it means a second region, tens of milliseconds away, which changes everything about how data moves. Other disasters do not care how many regions you have at all: someone runs DROP TABLE in production, a bug corrupts a week of records, ransomware encrypts the database, an account is compromised. Replication copies those mistakes to the replica in seconds. Replication is not a backup.

RPO and RTO

Every DR conversation starts with two numbers, set per system by the business, not by engineers.

  • RPO (recovery point objective): how much data you can afford to lose, measured in time. "RPO 5 minutes" means after a disaster you may lose at most the last 5 minutes of writes.
  • RTO (recovery time objective): how long you can afford to be down. "RTO 1 hour" means service is back within an hour of the decision to recover.

Lower numbers cost more, roughly exponentially. RPO of 24 hours is a nightly backup. RPO of minutes needs continuous log shipping. RPO of zero needs synchronous replication to another location, which adds that location's round-trip time to every write. RTO of a day can mean rebuilding from scratch; RTO of seconds means a second copy of everything already running and taking traffic.

Set them per system, not per company. The payments ledger might need RPO near zero and RTO of minutes. The internal analytics dashboard can have RPO of a day and RTO of a week. Treating everything as critical is how DR budgets get spent on the wrong things.

Quick check
A bug ships at 09:00 that silently corrupts order records. It is noticed at 15:00. The database has a synchronous replica in a second zone and an async replica in another region. What protects you?
Need a nudge? A hint rules out a wrong answer.

The four DR strategies

The AWS disaster recovery whitepaper names four strategies. The names are now common across clouds, and interviewers use them.

StrategyWhat runs in the recovery regionTypical RPOTypical RTORelative cost
Backup and restoreNothing; backups are copied thereHoursHours to a dayLowest
Pilot lightData is replicated; core infrastructure exists but app servers are offMinutesTens of minutesLow
Warm standbyA scaled-down but working copy of the whole stackSeconds to minutesMinutesMedium
Multi-site active-activeFull capacity, serving real trafficNear zeroNear zeroHighest

With backup and restore, recovery means provisioning everything from infrastructure as code and restoring data. It only works if your infrastructure really is in code: a region rebuilt by hand from a wiki page will blow any RTO. Pilot light keeps the data warm (a replicated database) and the rest switched off; recovery is "turn on and scale up". Warm standby runs everything at small scale, so it is tested constantly by health checks and can take traffic at once while it scales. Active-active serves users from both regions all the time, which removes "failover" as a special event but forces you to solve multi-region writes.

Match the pairs0/4 matched

Match each requirement to the cheapest strategy that meets it.

Choose an item, then its match on the other side.

Backups that count

A backup strategy for a database usually has two parts. Snapshots (full or incremental copies, daily) give a starting point. A continuous archive of the write-ahead log lets you replay changes from that snapshot up to any moment: this is point-in-time recovery (PITR). In Postgres you take base backups and archive WAL segments, typically with tools like pgBackRest or WAL-G; managed databases such as RDS and Cloud SQL do this for you within a retention window. Your RPO for logical disasters is how recently a WAL segment was shipped off the server, often seconds to a few minutes.

Rules seniors insist on:

  • 3-2-1: at least 3 copies of the data, on 2 different kinds of storage, with 1 copy off-site. The modern version adds one immutable or air-gapped copy (object lock, a separate account with no delete rights), because ransomware and compromised credentials go after backups first.
  • Back up to a different account and region. If the attacker or the outage takes your main account or region, backups stored there go with it.
  • An untested backup is not a backup. Schedule restore drills: restore last night's backup to a fresh instance, run checks against it, and time the whole thing. That time is your real RTO for the restore path. Teams regularly discover during an incident that backups were empty, missing a database, or take 14 hours to restore.

Data across regions

Inside one region, synchronous replication across zones is cheap. Across regions it costs a long round trip on every commit (often 60 to 100 ms or more between continents), so most cross-region replication is asynchronous: the primary commits locally and ships changes afterwards. That means RPO is greater than zero. Whatever was committed but not yet shipped when the region dies is gone.

Pythonfailover_rpo.py
# Async replication: region A commits, region B applies the change LAG seconds later.LAG = 2.0writes = [(t / 10, f"order-{t}") for t in range(1, 101)] # one order every 0.1 s for 10 sCRASH_AT = 10.0 # region A disappears here replicated = [name for t, name in writes if t + LAG <= CRASH_AT]lost = [name for t, name in writes if t + LAG > CRASH_AT]print(f"committed in A: {len(writes)} present in B: {len(replicated)} lost: {len(lost)}")print(f"first lost: {lost[0]}, last lost: {lost[-1]} (RPO is roughly the lag: {LAG} s)") # Active-active with last-writer-wins: two regions edit the same cart at once.cart_a = {"items": ["book", "pen"], "ts": 1000.002} # user adds a pen in region Acart_b = {"items": ["book", "mug"], "ts": 1000.001} # same user, other tab, adds a mug in Bwinner = max(cart_a, cart_b, key=lambda c: c["ts"])print("LWW result:", winner["items"]) # A CRDT-style merge for sets: union the adds instead of picking a winner.print("set merge:", sorted(set(cart_a["items"]) | set(cart_b["items"])))
Output
Press Run (⌘ Enter) to see what happens.

Those 20 lost orders were confirmed to customers. After a failover someone has to deal with them: reconcile from payment provider records, from logs, or from region A's disk if it comes back. So monitor replication lag as a first-class metric (it is your live RPO), and alert when it grows.

Predict the outputPython

Writes arrive at 500 per second and cross-region replication lag is steady at 3 seconds. Roughly how many committed writes are lost if the primary region vanishes?

writes_per_second = 500
lag_seconds = 3
print(writes_per_second * lag_seconds)
Need a nudge? Hints walk you through it.

Active-passive keeps one region as the writer and the other as a read-only replica that is promoted on failover. It is far simpler and is the right default. Active-active accepts writes in both regions, and then two users (or one user in two tabs) can change the same record in different regions at the same moment. Three ways to handle that:

  • Single writer per record (home region). Each user or tenant has a home region where their writes go; other regions serve reads and forward writes. No conflicts by construction, at the cost of extra latency for travellers and a failover process per home.
  • Last-writer-wins (LWW). Keep the version with the latest timestamp. Simple, and used by default in several multi-region databases, but as the code shows it silently drops one user's change, and clock skew between regions decides who "won".
  • CRDTs (conflict-free replicated data types). Data types designed so concurrent updates merge deterministically: counters, sets, maps. Good for carts, likes, and collaborative editing, but they do not fit invariants like "balance never below zero".

If you need strong consistency across regions, globally consistent databases (Spanner, CockroachDB, and similar) run consensus across regions. You pay for it in write latency, because every commit needs a majority of replicas in different regions to agree, as you saw in Consensus and Leader Election.

Routing users to the healthy region

Data is half the problem. The other half is getting traffic to the right place.

Active-passive failover between two regions
UsersUsersDNS / global LB: health-checkedDNS / global LBhealth-checkedApp: region AApp: region APrimary DB: region APrimary DBregion AApp: region B: warm standbyApp: region Bwarm standbyReplica DB: region BReplica DBregion Bprimaryfailoverasync replication

Normal operation. DNS (or a global load balancer) sends everyone to region A, which owns all writes.

1/6

Routing options, in rising order of speed:

  • DNS failover (for example Route 53 failover records with health checks). Simple and cheap, but clients and resolvers cache answers, and some ignore TTLs, so a few users keep going to the dead region for minutes.
  • Global load balancers and anycast. One IP address announced from many locations (AWS Global Accelerator, Google Cloud's global load balancer, Cloudflare). The provider shifts traffic between regions without waiting for DNS caches.
  • Client-side failover. Mobile apps and SDKs that know two endpoints can switch on their own.

The hardest decision is automatic vs manual. Automatic failover reacts in seconds, but a flapping health check, or a network partition where both sides think the other is dead, can fail you over for nothing, or back and forth, which is worse than the original problem. Many teams automate traffic shifting for stateless tiers and keep promotion of the primary database behind a human decision, or behind a carefully built quorum of signals. Whatever you choose, make the failover use data-plane operations that are expected to keep working during an outage (flipping a pre-created health check or routing control), not control-plane calls like "create a new load balancer", which may be exactly what is broken. AWS's Route 53 Application Recovery Controller is built around this idea.

Cells and blast radius

Multi-region protects against losing a region. It does nothing about the more common disaster: a bad deploy or bad config that you push everywhere. Cell-based architecture splits a service into many independent, identical copies (cells), each with its own servers and data, serving a slice of customers. A thin routing layer maps each customer to a cell. A poison request, a bad deploy, or a noisy tenant takes down one cell, perhaps 5% of customers, not all of them. You roll out changes cell by cell, watching SLOs, which makes every deploy a small, contained experiment. AWS builds many of its own services this way and has published guidance on it, and shuffle sharding extends the idea so that two customers rarely share the same set of cells.

Data residency

Multi-region is not only about uptime. Privacy laws such as GDPR restrict transferring personal data out of the EU without safeguards, and some countries and regulated industries require certain data to stay in-country. That pushes architectures toward regional data stores: EU customers' data lives in EU regions, and only anonymised or aggregated data crosses borders. This sits naturally with the home-region pattern above. It also means a "fail over to the US" plan may be illegal for EU data, so residency must be part of the DR design, not an afterthought. Get legal advice for the specific rules; the engineering job is to make the boundary enforceable.

Hidden single-region dependencies

On 19 and 20 October 2025, AWS's us-east-1 region had one of its largest outages in years.

AWS us-east-1, October 2025 (simplified from AWS's public summary)
  1. Trigger

    DynamoDB endpoint loses its DNS record

    A latent race condition in DynamoDB's automated DNS management left the regional endpoint with an empty DNS record. Anything resolving the endpoint could not reach DynamoDB.

  2. Hours 0 to 3

    DynamoDB errors, then a manual fix

    The automation could not repair itself. Engineers restored the record by hand, and DynamoDB recovered within a few hours.

  3. Knock-on

    Other AWS services that depend on DynamoDB

    Internal systems that use DynamoDB, including parts of EC2 instance launching and network load balancer health checks, had built up backlogs and kept failing after DynamoDB itself was fixed.

  4. Most of a day

    Long tail of recovery

    Throttles and backlogs were worked through over many hours. Customers saw failures in services they never thought of as depending on DynamoDB or on us-east-1.

The lessons for your own design are general. First, dependencies hide: your service may run in eu-west-1 but use an identity provider, a feature-flag service, a CI system, or a global control plane that lives in one other region. List every dependency on the critical path and ask where it runs. Second, recovery has its own failure mode: backlogs and retry storms (Reliability Patterns) kept systems down long after the root cause was fixed. Third, automation needs a manual override, and someone who knows how to use it.

Game days and chaos engineering

A DR plan you have never run is a hypothesis. Game days are planned exercises where you fail something on purpose (a zone, a database, a whole region in staging or even production) and watch the system and the people respond. Chaos engineering, made famous by Netflix's Chaos Monkey (which kills random production instances) and its region-level sibling Chaos Kong, does this continuously so that resilience is tested every day instead of once a year. Managed tools such as AWS Fault Injection Service and Gremlin inject faults like latency, packet loss, or instance termination in a controlled way.

Each exercise should produce two things: measured RTO and RPO (compare them with the targets), and fixes to the runbook, the step-by-step recovery document an on-call engineer can follow at 3 a.m. without the one person who designed the system.

Put it in order6 steps

Put the steps of a regional failover game day in order.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.
Key terms
RPO
Recovery point objective: the most data, measured in time, you can afford to lose in a disaster.
RTO
Recovery time objective: how long service may be down before it must be restored.
pilot light
A DR strategy where data is replicated to a second region but app servers stay off until needed.
warm standby
A DR strategy that keeps a scaled-down, working copy of the whole stack running in a second region.
point-in-time recovery
Restoring a database to any moment by replaying archived write-ahead logs on top of a snapshot.
fencing
Making sure an old primary can no longer accept writes before a new one is promoted, to avoid split brain.
cell-based architecture
Splitting a service into independent copies, each serving a slice of customers, so one failure hits only one cell.