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.
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.
The four DR strategies
The AWS disaster recovery whitepaper names four strategies. The names are now common across clouds, and interviewers use them.
| Strategy | What runs in the recovery region | Typical RPO | Typical RTO | Relative cost |
|---|---|---|---|---|
| Backup and restore | Nothing; backups are copied there | Hours | Hours to a day | Lowest |
| Pilot light | Data is replicated; core infrastructure exists but app servers are off | Minutes | Tens of minutes | Low |
| Warm standby | A scaled-down but working copy of the whole stack | Seconds to minutes | Minutes | Medium |
| Multi-site active-active | Full capacity, serving real traffic | Near zero | Near zero | Highest |
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 each requirement to the cheapest strategy that meets it.
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.
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.
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)
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.
Normal operation. DNS (or a global load balancer) sends everyone to region A, which owns all writes.
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.
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.
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.
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.
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 the steps of a regional failover game day in order.
- Tap the steps below in the right order.
- 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.