0 XP · 0 scenes

Multi-region, failover and disaster recovery

Reliability & Operations · lesson 7 of 9 · about 28 min

Multi-region, failover and disaster recovery

What happens when a whole region fails: how RPO and RTO define the four disaster-recovery strategies, why distance costs a fixed number of milliseconds, how long failover really takes with DNS or anycast, what active-active does to write conflicts, why untested plans fail, and why the surviving region must be sized for both. Tap any for a plain-language card.

0 / 9 sections done
  1. 1Disaster recovery5 min
  2. 2Distance has a price4 min
  3. 3Failover mechanics4 min
  4. 4Active-active4 min
  5. 5Testing the plan3 min
  6. 6Which strategy?3 min
  7. 7Who lives by this1 min
  8. 8Interview angle2 min
  9. 9Break It: the undersized survivor4 min

Words in this lesson12Tap one for its meaning.

Disaster recovery

The whole region goes dark. How much data do you lose, and how long are you down?

Every step up buys a smaller RPO and RTO at a higher bill, because you pay for more capacity sitting ready in another region. The figures below simulate a region lost at a random moment: backups run nightly, the replicated options copy asynchronously with the lag you set, and recovery time for backup-and-restore grows with the data size.

Make the data 200 TB and see backup-and-restore take days; the replicated options barely change. Then raise the replication lag.

  • Backup and restore
    back in 6.1 h · loses ~12.0 h · cost 1.05×
  • Pilot light
    back in 30 min · loses ~3 s · cost 1.15×
  • Warm standby
    back in 8 min · loses ~3 s · cost 1.60×
  • Active-active
    back in about 1 min · loses ~3 s · cost 2.00×
RPO: average data lost3 s
RPO: worst 1%23 s
RTO: time to recover8 min
Relative cost (illustrative)1.60×

Warm standby: losing the region costs on average 3 s of recent writes (23 s in the worst 1% of cases) and about 8 min to be serving again, at roughly 1.60 times the cost of a single region.

20,000 simulated disasters. Backup: nightly. Replicated options: log-normal lag with an occasional tenfold burst. Recovery: 30 min provisioning plus data ÷ restore speed; pilot light 30, warm standby 8, active-active 1 minute (illustrative). Cost multipliers are rough illustrations.

Distance has a price

You cannot make Frankfurt closer to Virginia. Every cross-region trip costs about 100 milliseconds.

This sets the design rules. A synchronous write that waits for another region to confirm adds a full round trip to every commit, so only about 1,000 ÷ RTT commits a second can be done one after another on one connection. A page that makes ten sequential calls across regions spends a second just in transit. So systems keep requests within a region, replicate asynchronously across regions, and accept some data loss on disaster (the RPO) in exchange for speed. The distances are approximate great-circle figures.

Choose London ↔ Singapore: ten sequential cross-region calls cost more than a second of pure travel time.

  • Two zones in one region
    0.9 ms
  • N. Virginia ↔ Oregon
    56 ms
  • N. Virginia ↔ Frankfurt
    98 ms
  • London ↔ Singapore
    162 ms
  • N. Virginia ↔ Mumbai
    188 ms
Distance (great circle)6,500 km
Round trip at best98 ms
Synchronous commits per second, one after another10
Time for 10 sequential calls975 ms

N. Virginia ↔ Frankfurt is 6,500 km apart, so a round trip takes at least 98 ms. Waiting for the far region to confirm every write limits one connection to about 10 commits a second, and 10 sequential cross-region calls add 975 ms of unavoidable travel time. This is why cross-region replication is normally asynchronous.

RTT = 2 × distance × route factor ÷ 200,000 km/s. Distances are approximate; real-world latency is higher because of routing and equipment.

Failover mechanics

The region is down at 12:00:00. Half of your users are still being sent to it at 12:03.

That is why failover with a 5-minute TTL takes five minutes after detection even if everything works. Shorter TTLs help at the cost of more DNS queries (and some resolvers ignore low TTLs). Global load balancers and addresses avoid the wait entirely: the same IP is announced from several regions and routing, or the balancer, simply stops sending to the failed one. Compare them.

Leave 30 s × 3 checks and a 300 s TTL on DNS: it takes about six minutes for 95% of users to move. Switch to anycast and it takes under two minutes.

100%003 min6 min10 min
Failure detected after90 s
Half of users moved after250 s
95% moved after380 s

Detection takes 90 seconds. With a 300-second TTL half of the users have moved after 250 s and 95% after 380 s; the rest keep hitting the dead region until their cached answer expires.

Model: clients' cached answers expire uniformly over one TTL after detection; anycast moves traffic within about a minute. Real resolvers can be slower or ignore short TTLs.

Active-active

Two regions both accepting writes will, sooner or later, both change the same record.

Conflicts then need a policy: (simple, silently loses one update), merge with a (counters, sets, text), keep both versions and ask the application (as in the Quorums lesson), or avoid them by design by assigning each record a home region and routing its writes there, which most real systems do. The figures are expected conflicts per day for a table of hot keys.

With 1,000 keys each written 10 times per 1,000 seconds in each region and a 1-second lag, there are about 17,000 conflicts a day, one every five seconds. Double the lag and the count doubles.

  • lag 0.1 s
    1,728 / day
  • lag 0.5 s
    8,640 / day
  • lag 1 s
    17,280 / day
  • lag 5 s
    86,400 / day
  • lag 20 s
    345,600 / day
Expected conflicts per day17,280
…per second0.20
Updates silently lost under last-write-wins17,280

1,000 hot keys, each written about 10 times per thousand seconds in both regions, with 1 s of lag between them produce roughly 17,280 conflicting write pairs a day. Under last-write-wins each one silently discards an update. That is too many to ignore: give each record a home region, or use merge-friendly data types.

Expected overlaps for independent Poisson writes: keys × a × b × 2 × lag, per second, scaled to a day. Skewed access to a few very hot keys makes it worse.

Testing the plan

Fifteen steps that each work 99% of the time give a plan that works 86% of the time. After a year of drift: 2%.

The remedy is to practise: scheduled where you fail over for real, automation so that the plan is code that is exercised, and regular drills that reset the clock. Netflix's Chaos Kong exercise evacuates an entire region of traffic on purpose. Set the plan's size, how reliable each step is when fresh, how fast it drifts and when it was last tested.

Leave 15 steps, 99% fresh, 2% monthly drift: a plan last tested a year ago works about 2% of the time. Drop the months to 1.

  • 0 months after a test
    86% likely to work
  • 3 months after a test
    35% likely to work
  • 6 months after a test
    14% likely to work
  • 12 months after a test
    2% likely to work
  • 24 months after a test
    0% likely to work
Chance the plan works, right after a test86%
Chance it works after 12 months2%

A 15-step plan where each step works 99% of the time succeeds 86% of the time when fresh. With 2% of steps breaking every month, one last tested 12 months ago works only 2% of the time. You do not have a disaster-recovery plan; you have a document.

P(plan works) = (p × (1 − drift)^months)^steps. Independent steps assumed; a simplification, but the direction is the point.

Which strategy?

Six businesses, four strategies.

Backup and restore is cheapest and slowest; pilot light keeps a core running; warm standby keeps a small full copy; active-active serves from everywhere. Match the strategy to the RPO, RTO and budget. Each answer is worth 20 XP.

Ask: how much data can we lose, how long can we be down, and what will we pay?

Question 1 / 6

An internal reporting tool: a day of lost data and a day of downtime are acceptable, and budget is tight.

Tip: press 1 to 4 to answer, Enter for the next one.

Who lives by this

From AWS's four strategies to Chaos Kong.

Four published sources on multi-region resilience.

The four strategiesAWS whitepaper

'Disaster Recovery of Workloads on AWS'

The AWS paper lays out backup and restore, pilot light, warm standby and multi-site active/active as increasing investments that reduce RTO and RPO, and recommends choosing from the business's recovery objectives instead of using the most expensive option by default.

A region goes badAmazon S3, 28 February 2017

US-EAST-1 outage

A mistyped command during debugging removed more S3 servers than intended in us-east-1 and the restart took hours, taking down many sites and services (and even AWS's own status page icons) that depended on that one region. The postmortem is a standard example of hidden regional dependencies.

Evacuating a regionNetflix Chaos Kong

regional evacuation drills

Netflix has described running an active-active architecture across AWS regions and regularly rehearsing evacuating all traffic from one region to the others, so that region-level failover is a practised operation rather than an emergency improvisation.

Replication that spans regionsGoogle Spanner

multi-region configurations

Spanner offers multi-region instance configurations that replicate synchronously across regions using Paxos to survive the loss of a region, advertised with a higher availability SLA than regional configurations, at the cost of higher write latency.

Interview angle

What interviewers actually ask.

Six questions, each worth 20 XP. Multi-region comes up whenever an interviewer asks what happens if a whole data centre or region fails.

State RPO and RTO first, then pick a strategy that meets them, and mention testing and capacity.

Question 1 / 6

What does RPO measure?

Tip: press 1 to 3 to answer, Enter for the next one.

Break it

Region A dies. Region B is 60% busy, so it should be fine. Now B is carrying 120% of its capacity and its caches are empty.

Two further traps. The refugees arrive with cold caches: the survivor's caches were warm for its own users, not for the other region's, so the database behind it takes several times its normal read load. And autoscaling may be too slow, or capped by quotas in the surviving region. The rule for N regions is to provision so that losing one still leaves each survivor under about 60 to 70% (for two regions, each below 50% in normal operation), and to rehearse it.

With each region at 60% and no spare capacity, B can serve only about 92% of the traffic and its database sees 3.6 times its normal load. Switch to full capacity in the survivor.

  • Load on the survivor
    120% of one region
  • Its capacity
    110%
Requests the survivor can serve92%
Database load on the survivor360% of its normal

Each region ran at 60%, so the survivor must take 120% of one region's capacity but only has 110%: about 8% of requests cannot be served, and with cold caches its database sees 3.6 times its normal load. The failover has become a second outage.

Load on the survivor = 2 × normal utilisation; capacity = 1 + headroom. Cold-cache database load = load × the multiple you choose (illustrative).

Where to go next