Course contents

09. Reliability and Resilience Lesson 10 of 10

Disaster Recovery

RPO and RTO, why replicas are not backups, and a simulated region failure under pilot light, warm standby and active-active recovery.

17 minIntermediate6 steps
Loading the interactive simulation…
Loading the knowledge check…

Summary

  • RPO is how much data you may lose; RTO is how long you may be down.
  • Replicas protect against losing infrastructure; only backups recover from bad writes and corruption.
  • Pilot light replicates data and boots compute on demand; warm standby runs small; active-active serves from both.
  • Lower RPO and RTO cost money and complexity; choose per system.
  • Only DR drills reveal the RPO and RTO you actually achieve.
Deep diveHow it works, trade-offs, failure modes, misconceptions and the interview angle.

What it is

Disaster recovery (DR) is the plan and machinery for restoring service after an event that takes out more than redundancy within a site can absorb: a region outage, a destroyed database, a ransomware attack, an operator deleting production data. It is measured by two objectives:

  • RPO (recovery point objective): the maximum acceptable data loss, measured in time. "RPO 5 minutes" means losing at most the last five minutes of writes.
  • RTO (recovery time objective): the maximum acceptable time from the disaster until the service works again.

Why it exists

High availability inside one region (multiple zones, replicas, failover) handles common failures. It does not help when the region itself is unavailable, when the failure is logical (a bad migration replicates everywhere in milliseconds), or when an attacker encrypts or deletes data. DR covers those cases, usually with a second region and backups kept apart from production.

How it works

Data: replicas and backups. Asynchronous cross-region replication keeps a copy seconds behind: the RPO for losing a region is roughly the replication lag. But replicas apply every change, including the wrong ones. Backups are point-in-time copies: periodic snapshots plus continuously archived transaction logs allow point-in-time recovery to just before a bad change. Keep them in a separate account and region, immutable (object lock, retention policies), and test restores. Restore time grows with data size, so backups alone mean long RTOs.

Compute and traffic. A global traffic manager (DNS failover with health checks, anycast, or a global load balancer) sends users to a healthy region. Region-level health checks and the traffic manager's own detection time are part of the RTO, plus clients caching DNS answers.

Strategies, from cheapest to most expensive:

Strategy What runs in the recovery region Typical RPO Typical RTO
Backup and restore Nothing; backups stored there Since last backup / log segment Hours
Pilot light Replicated data; compute off Seconds–minutes (replication lag) Tens of minutes or more
Warm standby Data plus a scaled-down full stack Seconds–minutes Minutes
Active-active Full stack serving live traffic Near zero to seconds About detection time

(Ranges are illustrative orders of magnitude; your numbers come from your drills.)

When to use it

Every production system needs at least backup and restore with tested restores. Choose higher tiers per system from the business cost of downtime and data loss: a payment API may justify active-active; an internal reporting tool may be fine with restoring from backup within a day.

When not to

  • Do not buy active-active for systems whose RTO target is hours: it adds multi-region data complexity for nothing.
  • Do not count replicas as backups, or backups in the same account and region as off-site protection.
  • Do not design a DR tier you will not rehearse: an untested plan gives a false sense of safety.

Trade-offs

Choice You gain You pay
Async cross-region replication Small RPO for region loss, no write latency Loses the lag on failover; replicates mistakes
Sync cross-region replication RPO ≈ 0 for region loss Cross-region round trip on every write
Warm standby over pilot light Shorter RTO, a tested running stack Paying for idle capacity
Active-active RTO ≈ detection, capacity in use Double capacity, multi-region writes and conflicts
Immutable off-site backups Survive ransomware and account compromise Storage cost, slower restores

Alternatives

  • Multi-zone high availability inside one region covers most outages with far less complexity; DR adds region-level and logical protection on top.
  • Cell-based architecture: split users into independent cells so a disaster hits only a fraction of them.
  • Globally distributed databases with consensus replication across regions make region failover a database feature, at the cost of write latency.

Failure modes

  • Restore never tested: backups exist but are corrupt, incomplete, or take ten times longer to restore than assumed.
  • Shared fate: backups in the same account that the attacker or the bad script also reached.
  • Undersized recovery region: traffic moves, then the survivor collapses under the full load.
  • Hidden single-region dependencies: identity provider, secrets, container registry or DNS control plane living only in the failed region.
  • Configuration drift: the standby region runs an old version or misses a migration.
  • Failing back: returning to the original region is a second migration with its own risks.

In production

Write RPO and RTO per system and get them agreed with the business. Automate the failover runbook as far as possible, keep it in version control, and run DR drills on a schedule: restore a backup into an empty account, fail a region on purpose, and time every step. Monitor replication lag against the RPO, backup success and age, and the capacity headroom of the recovery region. Keep a copy of the tooling needed for recovery (credentials, infrastructure code, runbooks) reachable when the primary region is not.

Common misconceptions

  • "We replicate to another region, so we have backups." Replicas copy deletions and corruption.
  • "RTO is how long the failover script runs." It includes detection, decision, scaling the recovery region, traffic shifting and client caches.
  • "Active-active means no outage." Requests in flight to the failed region still fail until it is detected and drained, and the survivor must have capacity for everything.
  • "Cloud providers handle DR." They provide building blocks; the plan, the drills and the data protection are yours.

Interview angle

State RPO and RTO targets early, then pick the cheapest strategy that meets them and justify it. Distinguish replication (region loss) from backups (logical errors). For multi-region designs, explain how traffic fails over, how long detection takes, whether the surviving region has capacity, and how writes work across regions. Mentioning immutable off-site backups and regular DR drills signals real operational experience.

Model assumptions

The engine runs traffic, region failures, health checks and replication; the backups step is a scripted illustration because the backup vault has no simulation model. Users send 120 req/s (Poisson, 20% writes). The traffic manager probes each region's load balancer every 1 s (3 failures eject, 2 successes restore); regional balancers probe app servers every 500 ms. Each app server has 6 workers and a 50 ms mean service time (about 90 req/s with its database call). DB A replicates to DB B asynchronously with about 0.4 s of lag. A region failure is all its nodes failing at once. Strategies differ only in what runs in Region B beforehand and when the rest is started or scaled; in the active-active step Region B's apps write to DB B and the model does not resolve cross-region write conflicts. Times are compressed: a simulated second stands for minutes in a real DR event. Numbers are illustrative, not benchmarks.

The lesson as textEvery step of the simulation, written out.
  1. 1. Plan for losing a whole region

    Users reach the service through a global traffic manager (DNS failover or a global front door). Region A serves everything. Region B is a pilot light: its database is a live replica of DB A, but its app servers and balancer are switched off to save money.

    Two numbers define any disaster-recovery plan. RPO (recovery point objective): how much recent data you may lose. Here it is about the replication lag, roughly 0.4 s of writes. RTO (recovery time objective): how long until users are served again. That depends on what still has to be started.

    Scene: Region A serves all traffic. In Region B only the database runs, as an asynchronous replica of DB A about 0.4 seconds behind; Region B’s balancer and app servers are off.

    Key idea: RPO = how much data you can lose; RTO = how long you can be down. Every DR strategy is a price for a pair of them.

  2. 2. A replica copies your mistakes too

    A scripted illustration (live traffic keeps running underneath). DB A takes a nightly snapshot to a backup vault in another account and region, and archives its write-ahead log there continuously.

    At 2 s a bad migration runs DELETE FROM orders without a WHERE. Replication does exactly its job: within about half a second the replica has deleted the rows too. Replicas protect against losing hardware or a region, not against bad writes, bugs or ransomware.

    The backup can: restore the snapshot and replay the log up to the second before the delete (point-in-time recovery). The restore is slow, roughly proportional to the data size, so it brings a long RTO.

    Scene: Scripted: DB A sends a snapshot and log segments to the backup vault. A bad delete at 2 seconds replicates to DB B within half a second. A slow restore then flows from the vault back to DB A, to the point just before the delete.

    Key idea: Replicas give a small RPO for infrastructure loss; only backups (ideally immutable and off-site) recover from logical corruption.

  3. 3. Region A fails: pilot light recovery

    At 1 s all of Region A fails. The traffic manager needs three failed probes (until 4 s) to give up on it, and then has nowhere to send users: Region B’s app tier is off.

    At 5 s the runbook has started Region B: the replica is promoted, the balancer and app servers boot. At 7 s the traffic manager has seen two good probes and sends users to Region B. RTO ≈ 6 s here; in real life, starting and warming a region usually takes tens of minutes to hours. The data in DB B is up to the last ~0.4 s before the failure.

    Scene: Region A fails at 1 second. Every request fails until 7 seconds: the traffic manager ejects Region A at 4 seconds, Region B’s app tier is started at 5 seconds and receives traffic from 7 seconds.

    Key idea: Pilot light: cheap (only data is replicated), but the RTO includes booting a whole region under pressure.

  4. 4. Warm standby: running, but small

    Region A is back. Region B now runs all the time, scaled down: its balancer and one app server with only 2 workers. The traffic manager sends it no users (weight 0) while Region A is healthy.

    Region A fails again at 1 s. As soon as it is ejected (4 s), Region B takes all traffic. It is too small, so it is overloaded: many requests are rejected, but some are served. At 6 s autoscaling has added App B2 and grown App B1, and the errors stop by about 7 s. The outage is shorter than with a pilot light, and the region you fail over to has been tested by running all along.

    Scene: Region B runs a small app tier that receives no traffic. When Region A fails at 1 second, all traffic moves to Region B at 4 seconds; it is overloaded and rejects many requests until it scales up at 6 seconds, after which requests succeed.

    Key idea: Warm standby trades a running bill for a shorter RTO: traffic can move as soon as the failure is detected, then capacity catches up.

  5. 5. Active-active: both regions serve all the time

    Both regions are full size and each serves half of the users, about one third busy. When Region A fails at 1 s, only the requests sent to Region A fail, and only until the traffic manager ejects it at 4 s. Region B already runs and has room for everything: it carries all 120 requests per second at about two thirds busy.

    This is the shortest RTO, and the most expensive and complex option: each region needs capacity for the whole load, and if both regions take writes, the data layer has to handle it (a database built for multi-region writes, or partitioning users by home region). This model only shows routing and capacity; here Region B’s apps write to DB B.

    Scene: Both regions serve half the traffic. When Region A fails at 1 second, about half of the requests fail until the traffic manager ejects it at 4 seconds; Region B then serves everything without errors.

    Key idea: Active-active: failover is just rerouting, so RTO ≈ detection time. You pay for double capacity and for multi-region data.

  6. 6. Choose by RPO, RTO and budget, then rehearse

    Both regions are healthy and active again.

    The ladder, from cheap to expensive: backup and restore (RPO = time since the last backup or log segment, RTO = hours), pilot light (data replicated, compute started on demand: RPO seconds to minutes, RTO tens of minutes or more), warm standby (a small copy always running: RTO minutes), active-active (RTO ≈ detection, double capacity, hardest data model). Pick per system: a reporting tool and a payment API rarely deserve the same tier.

    A DR plan you have never executed is a hope. Run regular DR drills (fail a region on purpose, restore a backup into a fresh account), keep runbooks current, keep backups immutable and in a separate account, and measure the RPO and RTO you actually achieve.

    Scene: Both regions are healthy and each serves about half of the traffic. DB A replicates to DB B with about 0.4 seconds of lag. Every request succeeds.

    Key idea: DR tiers buy lower RPO and RTO with money and complexity. Only drills tell you which numbers you really have.