Multi-Region and Disaster Recovery

Surviving the loss of a data centre or a whole region: RPO/RTO, backups, active-passive vs active-active, failover, cells and game days.

What is it?

Servers fail, so you run several. But a whole data centre or cloud region can fail too: power, network cuts, a bad config pushed everywhere, a cloud provider incident. Data can also be lost without any outage: a buggy migration, an accidental DELETE, ransomware.

Disaster recovery (DR) is the plan for getting back to a working state after those events. Two numbers frame every DR decision:

- RPO (Recovery Point Objective): how much data you can afford to lose, measured in time. RPO of 5 minutes means losing at most the last 5 minutes of writes. - RTO (Recovery Time Objective): how long you can be down. RTO of 1 hour means service must be back within an hour.

Lower RPO and RTO cost more: more replicas, more regions, more complexity. The job is to pick targets per system based on business impact, then design the cheapest architecture that meets them, and prove it with regular drills. An untested DR plan is a hope, not a plan.

Explain like I'm 10

RPO is how many pages of your essay you'd lose if your laptop died: autosave every minute means one minute of work. RTO is how long until you're writing again: a spare laptop on the desk is minutes, ordering a new one is days. Backups in the same bag as the laptop don't help if the bag is stolen.

Examples

Choosing a DR tier per system

System              RPO        RTO        Strategy
------------------  ---------  ---------  ---------------------------------------
Payments ledger     ~0         < 5 min    Multi-region, synchronous/consensus writes
Product catalog     5 min      30 min     Warm standby, async replication
Search index        rebuild    4 h        Rebuild from source of truth + snapshots
Analytics warehouse 24 h       24 h       Daily backups to another region
Internal wiki       24 h       72 h       Backup and restore

Not everything needs active-active. Tiering by business impact keeps cost proportional to risk.

DNS-based failover with health checks (Route 53 style)

# Primary record answers while its health check passes.
- name: api.example.com
  type: A
  set_identifier: primary-us-east-1
  failover: PRIMARY
  alias_target: alb-us-east-1
  health_check: api-us-east-1-deep-health   # checks DB writes, not just "200 OK"
# Secondary takes over when the primary is unhealthy.
- name: api.example.com
  type: A
  set_identifier: secondary-us-west-2
  failover: SECONDARY
  alias_target: alb-us-west-2
# Keep TTLs low (e.g. 60 s) so clients move quickly; some resolvers cache longer anyway.

Traffic failover is the easy half. The hard half is making sure the secondary's data is current and that the old primary stops accepting writes.

Cell-based routing

// A thin, highly reliable router maps each customer to one cell.
// Each cell is a full, independent copy of the stack with its own data.
function cellFor(customerId: string): string {
  const pinned = cellAssignments.get(customerId); // explicit overrides, migrations
  if (pinned) return pinned;
  return CELLS[hash(customerId) % CELLS.length];
}

A bad deploy or poison request takes down one cell (a fraction of customers), not everyone. Deploy to cells one at a time.

How it works

Backups. The baseline for every system, even multi-region ones, because replication faithfully copies mistakes (a dropped table replicates in milliseconds). - Full + incremental backups, plus point-in-time recovery from write-ahead logs or binlogs. - 3-2-1 rule: 3 copies, 2 different media/services, 1 off-site (another region or account). Add an immutable or logically air-gapped copy against ransomware and compromised credentials. - Test restores regularly. Restore time for 20 TB is your real RTO for that path, and it's often hours.

DR strategies, in rising cost and falling RPO/RTO: 1. Backup and restore: rebuild infrastructure and restore data in another region. RPO hours, RTO hours to days. 2. Pilot light: data replicated continuously, core infrastructure provisioned but scaled to zero. Scale up on failover. 3. Warm standby: a smaller full copy running and receiving replicated data. Scale up and switch traffic. Minutes. 4. Active-active (multi-site): every region serves live traffic. Failover is just shifting traffic. Seconds to minutes.

Active-passive is simpler: one region takes writes, others replicate asynchronously. The catch: async replication means an unplanned failover loses whatever hadn't replicated (RPO > 0), and you must fence the old primary so it can't keep accepting writes (split brain).

Active-active means each region accepts traffic. For reads it's easy. For writes you need one of: - Partition ownership: each user/tenant is "homed" in one region, so writes for a given key go to one place. - Synchronous consensus across regions (Spanner, CockroachDB): RPO ≈ 0, but every write pays cross-region latency (tens of ms or more). - Multi-leader with conflict resolution (last-writer-wins, CRDTs): low latency, but you must accept and resolve conflicts.

Failover mechanics. Detect (health checks with sensible thresholds to avoid flapping), decide (automatic for fast RTO, human-confirmed for risky data paths), promote the replica, fence the old primary, shift traffic (DNS, anycast, global load balancer), then fail back later with the same care. Make sure the standby has capacity: if every customer in Europe fails over to one other region, can it take 2x load? Cloud capacity in the target region may be scarce during a regional incident, so some teams pre-provision.

Data residency. Laws such as GDPR and sector rules can require some data to stay within a jurisdiction. That constrains where replicas and backups may live, and can force per-region data stores with only anonymised or aggregated data crossing borders.

Cell-based architecture. Split the system into many identical, independent cells, each serving a subset of customers with its own compute and data. A thin routing layer maps customers to cells. Failures, bad deploys and noisy tenants are contained to one cell (smaller blast radius), and you scale by adding cells. The router must be extremely simple and reliable, since it's shared.

Chaos engineering and game days. Deliberately inject failures in a controlled way to verify the system and the team respond as designed. Netflix's Chaos Monkey randomly terminates instances; game days are scheduled exercises, such as failing over a region, with clear abort criteria and a small blast radius to start.

Active-passive                          Active-active (users homed per region)

  users                                   EU users          US users
    |                                        |                  |
    v                                        v                  v
+----------+   async repl   +----------+  +----------+      +----------+
| Region A | -------------> | Region B |  | Region A | <--> | Region B |
| primary  |                | standby  |  | home: EU |repl. | home: US |
+----------+                +----------+  +----------+      +----------+
RPO = replication lag                     each region writes its own users;
RTO = detect + promote + DNS              on failure, the other region takes over

Backups (separate account, immutable) ---> restore anywhere

Why does it exist?

Single-region systems are exposed to events no amount of in-region redundancy fixes, and data loss from human error or attack is a far more common "disaster" than a region going dark. DR planning turns these from existential risks into rehearsed procedures with known costs, and it's often a contractual or regulatory requirement.

When to use it

- Every production system needs backups with tested restores and a written RPO/RTO, even if the answer is "24 hours is fine". - Warm standby or active-passive when downtime is costly but some data loss on a rare regional failure is tolerable. - Active-active when you need near-zero RTO, global low latency, or both, and can afford the data-model work. - Cells for large multi-tenant SaaS where one tenant or deploy must not take down everyone.

When not to use it

- Don't go active-active for a small product whose users tolerate an hour of downtime per year. The complexity often causes more outages than it prevents. - Multi-region isn't a substitute for backups: replication copies corruption and deletes. - Synchronous cross-region writes are wrong for latency-sensitive paths that don't need RPO 0; the latency is paid on every write.

Common mistakes

  • Never testing restores, then discovering during an incident that backups are incomplete, corrupt or take days to restore.

  • Keeping backups in the same account and region as production, so one compromised credential or regional outage takes both.

  • Failing over without fencing the old primary, leading to split brain and two divergent copies of the data.

  • Shallow health checks that return 200 while the database behind them is down, so failover never triggers (or triggers on harmless blips).

  • Forgetting shared dependencies: DNS, identity provider, secrets store, CI/CD or a control plane that only exists in the failed region.

Practice exercises

  1. Easy:

    Define RPO and RTO and give an example system where RPO matters more than RTO.

  2. Medium:

    A Postgres primary in one region replicates asynchronously to another. Write the step-by-step runbook for an unplanned regional failover, including fencing and how you measure data lost.

  3. Hard:

    Design an active-active architecture for a global SaaS app with EU data-residency requirements, a 1-minute RTO and near-zero RPO for billing data. Explain data placement, write routing, conflict handling and how you'd run a game day.

Interview questions

What are RPO and RTO?

RPO is the maximum acceptable data loss measured in time; RTO is the maximum acceptable time to restore service. They drive the choice of backup and replication strategy.

Why do you still need backups if data is replicated to another region?

Replication copies everything, including accidental deletes, bad migrations and ransomware encryption. Backups with point-in-time recovery let you go back to before the mistake.

What is the 3-2-1 backup rule?

Keep at least three copies of data, on two different kinds of storage or services, with one copy off-site. Modern practice adds an immutable or isolated copy.

Compare backup-and-restore, pilot light, warm standby and active-active.

In order of cost and speed: rebuild from backups (hours+), keep data replicated with minimal idle infrastructure (tens of minutes), run a scaled-down live copy (minutes), and serve from all regions at once (seconds).

What is RPO for an unplanned failover with asynchronous replication?

Roughly the replication lag at the time of failure: any writes acknowledged by the primary but not yet replicated are lost unless the old primary is recovered later.

What is split brain, and how do you prevent it during failover?

Two nodes both believe they're the primary and accept writes, causing divergence. Prevent it by fencing the old primary (revoke its access, STONITH, fencing tokens) and using a consensus-based or single authoritative failover decision.

How do you handle writes in an active-active setup?

Either home each key or tenant in one region so writes for it go to one place, use cross-region consensus (higher latency, RPO 0), or accept concurrent writes with multi-leader replication and resolve conflicts with LWW or CRDTs.

What is cell-based architecture and what does it buy you?

The system is split into independent, identical cells, each serving a subset of customers with its own resources. It limits blast radius of failures and bad deploys, and scales by adding cells. The cost is a routing layer and cross-cell operations.

How does data residency affect DR design?

It limits where primary data, replicas and backups may live. You may need DR within the same jurisdiction (two EU regions), per-region data stores and routing, and controls to keep personal data from replicating elsewhere.

How would you build confidence that a regional failover actually works?

Run it regularly as a game day: start in staging, then fail over real production traffic for a subset in a quiet window, with abort criteria. Measure actual RTO and RPO, verify capacity and hidden single-region dependencies, and fix gaps. Some teams make failover routine by moving traffic between regions weekly.