Library

Volume 1 · System Architecture & Distributed Systems

Notebook
Sign in

Section 4

Disaster Recovery

1,254 words · about 6 min

4.1 RTO vs. RPO — The Critical Distinction

timeline
    title Disaster Recovery Timeline (RPO vs RTO)
    section Data Loss Period
        Last Sync / Backup Point : RPO Window begins
        Disaster Event : Data Loss = Delta between Backup & Disaster
    section Service Outage Period
        Disaster Detected : Failover sequence initiated
        DNS / Traffic Cutover : Infrastructure provisioning
        Service Fully Restored : RTO Window ends
  • RPO (Recovery Point Objective): The maximum tolerable data loss measured backwards from disaster occurrence. Determined by synchronization frequency (synchronous vs. asynchronous replication).
  • RTO (Recovery Time Objective): The maximum tolerable system downtime before operations are restored. Dictated by failover automation, health checks, and boot-up latency.

Architect’s Rule: RTO and RPO are business decisions, not technical ones. Your responsibility is to map business downtime costs against the corresponding price tag of each DR tier.

4.2 DR Strategy Comparison

Strategy RTO RPO Relative Cost Description
Backup & Restore Hours Hours Lowest Periodic snapshots stored in cold object storage; infrastructure restored on disaster
Pilot Light 10–30 min Minutes Low Continuous data layer replication; application compute scaled to zero until disaster
Warm Standby Minutes Seconds Medium Continuously running, reduced-capacity fleet in standby region ready for immediate auto-scaling
Multi-Site Active-Active Seconds Near-zero Highest Full production deployments in 2+ regions simultaneously serving live client traffic

4.3 Pilot Light Architecture

flowchart LR
    subgraph PrimaryRegion["Primary Region (Active - 100% Traffic)"]
        App1["Full Compute Fleet\n(Auto-Scaled Containers)"]
        DB1[("Primary DB\n(Read / Write)")]
        App1 --> DB1
    end

    subgraph DRRegion["DR Region (Pilot Light - Standby)"]
        App2["Minimal Compute Fleet\n(0 or 1 Node Running)"]
        DB2[("Read Replica\n(Continuous Async Replicate)")]
    end

    DB1 -.->|Continuous Async Replication| DB2

    subgraph DisasterCutover["Failover Execution (10-30 min)"]
        direction TB
        F1["1. Promote DB Replica to Primary"]
        F2["2. Auto-scale compute fleet to 100%"]
        F3["3. Re-route DNS (Route 53 / Traffic Mgr)"]
        F1 --> F2 --> F3
    end

4.4 Warm Standby Architecture

flowchart LR
    subgraph PrimaryRegion["Primary Region (Active - 100% Traffic)"]
        AppP["Application Cluster\n(10+ Instances Active)"]
        DBP[("Primary Database\n(Read / Write)")]
        AppP --> DBP
    end

    subgraph StandbyRegion["DR Region (Warm Standby - Scaled Down)"]
        AppS["Pre-Warmed Cluster\n(2 Instances Running)"]
        DBS[("Standby Database\n(Sync / Near-Sync Read Replica)")]
        AppS -.-> DBS
    end

    DBP -.->|Real-time Replication| DBS

    subgraph WarmFailover["Immediate Failover (< 5 min)"]
        direction TB
        W1["1. Promote Read-Only DB to Master"]
        W2["2. Burst-scale app instances (2 → 10+)"]
        W3["3. Flip Global LB / Health-Check Target"]
        W1 --> W2 --> W3
    end

4.5 Multi-Site Active-Active Architecture

flowchart TD
    GLB["Global Anycast DNS / Global Load Balancer\n(Route 53 / Cloudflare / Azure Front Door)"]

    subgraph RegionUS["Region 1: Americas (Active)"]
        AppUS["Compute Tier (US)"]
        DBUS[("Globally Replicated DB (US)")]
        AppUS <--> DBUS
    end

    subgraph RegionEU["Region 2: Europe (Active)"]
        AppEU["Compute Tier (EU)"]
        DBEU[("Globally Replicated DB (EU)")]
        AppEU <--> DBEU
    end

    GLB -->|50% Live Traffic| AppUS
    GLB -->|50% Live Traffic| AppEU
    DBUS <-.->|Bi-Directional Multi-Master / CRDT Replication| DBEU

Prerequisites for True Active-Active:

  • Entity Affinity: Route writes for a customer aggregate to a home region to eliminate concurrent conflict spikes.
  • Conflict Resolution Protocols: Last-Write-Wins (LWW), vector clocks, or Conflict-Free Replicated Data Types (CRDTs).
  • Zero Cold-Boot Latency: Both regions actively receive live production traffic, guaranteeing instant failover without spin-up delays.

4.6 DR Strategy Decision Framework

flowchart TD
    Q1{"What is the business tolerance\nfor downtime and data loss?"}
    Q1 -->|RTO: Hours\nRPO: Hours| DR1["Tier 1: Backup & Restore\n(Cold Cloud Storage)"]
    Q1 -->|RTO: 10-30 min\nRPO: Minutes| DR2["Tier 2: Pilot Light\n(Replicated DB + On-Demand Compute)"]
    Q1 -->|RTO: < 5 min\nRPO: Seconds| DR3["Tier 3: Warm Standby\n(Pre-warmed fleet + Rapid scale-up)"]
    Q1 -->|RTO: ~0 sec\nRPO: ~0 sec| DR4["Tier 4: Multi-Site Active-Active\n(Simultaneous dual-region routing)"]

4.7 Section 4 — Interview Q&A

Q1: A stakeholder says “we need zero downtime and zero data loss.” How do you respond?

A: I’d translate that into concrete numbers first — “zero downtime” and “zero data loss” as literal absolutes are extraordinarily expensive and, for most systems, unnecessary. I’d ask what RTO and RPO the business can actually tolerate, and more importantly, what it costs the business per minute of downtime or per record of data loss — that’s what justifies the DR spend. If the honest answer is “we really do need near-zero,” I’d design multi-site active-active with synchronous or near-synchronous cross-region replication for the critical data path, accepting the added write latency and the roughly 2-3x infrastructure cost that comes with running full capacity in two-plus regions simultaneously. But in my experience, once stakeholders see the cost curve — pilot light at $X, warm standby at 3X, active-active at 6-8X — the actual tolerance turns out to be “RTO under 15 minutes, RPO under a minute,” which a well-implemented warm standby or pilot light satisfies at a fraction of the cost.

Q2: What’s the difference between pilot light and warm standby, and how do you decide between them?

A: Both keep a secondary region ready, but pilot light keeps only the data layer continuously replicating (a database read replica, for instance) while the compute/application layer is scaled to near-zero or entirely absent until disaster strikes — recovery means promoting the database and then standing up and scaling the application tier from scratch, typically 10-30 minutes. Warm standby keeps a smaller but fully deployed and running copy of the entire stack — application tier included — so recovery is just promoting the database and scaling the already-running application tier up to handle full load, typically single-digit minutes. I choose pilot light when the RTO tolerance is in the tens-of-minutes range and the cost of keeping application servers running 24/7 in an idle region isn’t justified; I choose warm standby when RTO needs to be under 5-10 minutes or when the application has a slow cold start (large JVM heap warm-up, extensive connection pool initialization) that would blow the RTO budget if starting from zero.

Q3: How do you test a disaster recovery plan without causing an actual outage?

A: Regular, scheduled game-day exercises — not a tabletop discussion, an actual failover. Start in a non-production environment: trigger a real failover of the DR replica to primary, redirect a synthetic traffic generator to the DR region, and measure actual RTO/RPO against the target. Once confidence is established, escalate to production game days during low-traffic windows, with a clear rollback plan and stakeholder sign-off — many mature organizations do this quarterly or even do continuous, automated “chaos” failover testing (in the spirit of Netflix’s Chaos Monkey) so that failover isn’t a rare, high-stakes event but a routine, well-rehearsed procedure. The single biggest DR risk I’ve seen isn’t a missing plan — it’s an untested one that turns out to have a broken runbook, an expired credential, or a DNS TTL that’s too high, discovered only during a real incident.

Q4: Explain how you’d handle data conflicts in a multi-site active-active architecture where the same record can be written in two regions simultaneously.

A: First, I try to avoid the conflict entirely by routing writes for a given entity consistently to one “home” region (e.g., based on the customer’s primary region), so that most entities never actually see concurrent cross-region writes even in an active-active topology — this is often called “active-active with entity affinity.” For the cases where true concurrent writes to the same entity are possible, I pick a conflict resolution strategy up front: Last-Write-Wins with synchronized clocks (simple, but can silently drop a legitimate concurrent update), vector clocks to detect and surface conflicts for manual or business-rule resolution, or CRDTs (Conflict-free Replicated Data Types) for data structures where merges can be defined mathematically to always converge without data loss (e.g., counters, sets). I reserve CRDTs for narrow, well-understood data types — they’re powerful but not a drop-in replacement for general relational data.