Skip to main content

High Availability & Disaster Recovery

Learning objectives
  • Compute availability for serial and redundant components and translate nines into downtime budgets
  • Choose between active-passive and active-active, and between multi-AZ and multi-region, for a given RPO/RTO and budget
  • Design a backup strategy that survives operator error and ransomware, and actually restores
  • Map business requirements to DR tiers: backup-restore, pilot light, warm standby, multi-site
  • Plan chaos experiments and DR drills, and explain how to keep balances correct during a regional failover

TL;DR​

  • High availability (HA) keeps a service running through component failures (pod, node, AZ). Disaster recovery (DR) restores service after a large-scale event (region loss, data corruption, ransomware). You need both, and they are tested differently.
  • Serial dependencies multiply availability (five 99.9% components in a chain ≈ 99.5%); redundancy improves it (1 − product of failure probabilities) — but only if failures are independent.
  • RPO = how much data you can lose (time); RTO = how long you can be down. Both are business decisions with a price tag; replication mode determines RPO, automation and readiness determine RTO.
  • Multi-AZ handles most failures cheaply with synchronous replication; multi-region handles regional disasters but forces a choice between async replication (RPO above 0) and slow cross-region consensus.
  • DR tiers trade cost for recovery time: backup & restore (hours) → pilot light (tens of minutes) → warm standby (minutes) → multi-site active-active (near zero).
  • For money, never let two regions accept conflicting writes for the same account. Use a single writer per account (home region), fencing, idempotency keys and post-failover reconciliation.
  • An untested DR plan is a hypothesis. Run game days and failover drills; banks are usually required to.

Why it matters​

When a bank's mobile app is down on salary day, customers cannot pay rent and the story reaches the news; regulators then ask for an incident report, the root cause and the evidence of your last DR test. When an e-commerce checkout is down for 30 minutes during 11.11, the lost revenue can exceed the annual cost of the redundancy that would have prevented it. Conversely, multi-region active-active for an internal reporting tool wastes money that should have gone to the ledger.

Interviewers test whether you can quantify ("what does 99.99% allow per month?"), reason about dependencies ("your service is 99.99% but depends on a 99.9% PSP"), and protect money during failover ("what happens to in-flight transfers when you fail over?").

Core concepts​

Availability math​

Availability = uptime / (uptime + downtime), often expressed via mean time between failures and mean time to repair: A = MTBF / (MTBF + MTTR). Reducing MTTR (fast detection, automated failover, quick rollback) is usually cheaper than increasing MTBF.

AvailabilityDowntime per yearPer 30-day monthPer week
99%≈ 3.65 days≈ 7.2 h≈ 1.7 h
99.9%≈ 8.8 h≈ 43 min≈ 10 min
99.95%≈ 4.4 h≈ 22 min≈ 5 min
99.99%≈ 53 min≈ 4.3 min≈ 1 min
99.999%≈ 5.3 min≈ 26 s≈ 6 s

Serial (all must work): A = A₁ × A₂ × … × Aₙ

Parallel (any one suffices): A = 1 − (1 − A₁) × (1 − A₂) × … × (1 − Aₙ)

Worked example: 0.9999 × 0.9995 × 0.999 × 0.9995 × 0.999 ≈ 0.9969 — about 2.2 hours of downtime per month, even though no component is worse than 99.9%. Adding a second PSP with failover turns the PSP term into 1 − 0.001² ≈ 0.999999, lifting the chain to ≈ 99.79%. The remaining weak links are now the payment service and its database.

Caveats you should say out loud:

  • Independence is an assumption. Two replicas in the same rack, sharing a config push, a certificate, a DNS provider or a bug, fail together. Correlated failures dominate real outages.
  • Failover is itself a component with its own failure probability (detection, promotion, client reconnection).
  • Soft dependencies do not count if you degrade gracefully: recommendations failing should not reduce checkout availability. Making dependencies soft is the cheapest availability improvement.

Redundancy​

ModelMeaningExample
NExactly the capacity needed4 pods for peak load — one failure degrades service
N+1One spare unit5 pods; any one may fail
N+2Two spares (one in maintenance, one failure)Critical payment APIs during patching windows
2NFull duplicate capacityActive-passive data centres; each can run the full load
Zone-redundantCapacity remains after losing one zone3 zones × 2 pods with peak needing 4

Remove single points of failure layer by layer: DNS, CDN, load balancers, NAT gateways, ingress controllers, service instances, databases, message brokers, HSMs, network links to the switch, and people (one engineer who knows how to fail over).

Active-passive vs active-active​

Active-passiveActive-active
Normal operationOne site serves; other replicatesBoth serve traffic
FailoverPromote standby, redirect traffic (minutes)Shift traffic from failed site (seconds–minutes)
Write conflictsNone (single writer)Must be designed away: partitioning, consensus or CRDT-style merges
Capacity costStandby may be smaller (warm) or full (hot)Each site needs headroom to absorb the other's load
Confidence in failoverLower unless drilled — the standby is not exercised dailyHigher — both sites carry real traffic
Typical useBank core systems, databasesStateless tiers, read-heavy catalogs, partitioned user data

Active-active for stateless tiers is easy; for state it is hard. Most "active-active" bank architectures are active-active for channels and APIs, with each account's writes owned by one region at a time.

Multi-AZ vs multi-region​

Multi-AZ (one region)Multi-region
Protects againstData-centre-level failures: power, cooling, network in one zoneRegional disasters, regional control-plane outages, large network events
Latency between sitesLow (typically single-digit ms or under)Tens of ms within a continent, 100+ ms across oceans
Synchronous replicationPractical — RPO 0 with modest write latency costExpensive — every commit waits a cross-region round trip
Complexity and costModerate; many managed services support it nativelyHigh: data replication, global routing, duplicated infra, data residency
Typical target99.95–99.99% for most servicesNeeded for very high availability goals or regulatory DR site requirements

Bank note: regulators often require a secondary data centre at a minimum geographic distance; for on-prem banks this is literally two (or three) sites, sometimes in different cities. In-country data residency may rule out using a foreign cloud region as DR.

RPO and RTO​

  • RPO (Recovery Point Objective) — maximum acceptable data loss measured in time. Determined by replication and backup: synchronous replication → RPO 0 for that failure scope; async replication → seconds to minutes; nightly backups → up to 24 h.
  • RTO (Recovery Time Objective) — maximum acceptable time to restore service. Determined by detection time, decision time (often the longest — who is allowed to declare a disaster?), automation and how warm the standby is.
  • Related: MTD / MTPD (maximum tolerable downtime) from business continuity planning, and WRT (work recovery time) for verifying data before reopening.

Typical targets (illustrative, set per business impact analysis):

SystemRPORTO
Bank ledger / core postings0 (no committed transaction lost)Minutes to ≈ 2 h depending on regulation and tier
Payment initiation API0 for accepted paymentsMinutes
E-commerce checkout and orders≈ 0–1 minMinutes
Product catalogMinutes–hours (rebuildable from source)Minutes (serve from cache/CDN)
Analytics warehouseHoursHours–a day

Backup strategies​

  • Full / incremental / differential: full is simplest to restore; incremental is cheapest to take; differential is in between. Combine (weekly full + daily incremental).
  • Point-in-time recovery (PITR): base backup plus continuous WAL/binlog archiving lets you restore to just before an operator error ("someone ran DELETE without WHERE at 14:03"). Replication does not protect against this — the deletion replicates instantly.
  • 3-2-1 rule: three copies, on two different media/storage types, one off-site. Modern variants add one immutable or air-gapped copy (object lock / WORM) and zero errors in restore tests — essential against ransomware that targets backups first.
  • Encrypt backups, manage keys separately, and restrict who can delete backups (separate account, MFA delete).
  • Test restores regularly and measure restore time; a 20 TB database that takes 14 hours to restore cannot meet a 2-hour RTO, no matter what the backup policy says.
  • Retention is driven by regulation (financial records are typically retained for years; check the jurisdiction) and by how long corruption might go unnoticed.

DR tiers​

These four strategies are described in the AWS disaster recovery whitepaper; the ideas apply on-prem too.

TierWhat runs in the DR siteRPO / RTO (rough)CostFits
Backup & restoreNothing; backups copied off-siteHours / hours–dayLowestInternal tools, analytics
Pilot lightDatabases replicating; app servers defined in IaC but off or minimalMinutes / tens of minutesLow–mediumSupporting systems with moderate RTO
Warm standbyFull stack at reduced capacity, continuously runningSeconds / minutesMedium–highPayment APIs, order platform
Multi-site active-activeFull stack serving production traffic in each siteNear zero / near zero for stateless; data depends on designHighestChannels, high-revenue checkout, systems with very high availability goals

Chaos engineering and failover testing​

The Principles of Chaos Engineering (principlesofchaos.org): define steady state by business metrics, hypothesize it continues during a fault, inject real-world faults, run in production where safe, automate, and minimize blast radius.

  • Experiments: kill pods, drain a node, black-hole a dependency, add 300 ms latency to the PSP, fail a database primary, expire a certificate, fill a disk, partition an AZ.
  • Tools: Chaos Mesh, LitmusChaos, AWS Fault Injection Service, Azure Chaos Studio, Gremlin, Toxiproxy for local tests; Netflix's Chaos Monkey popularized the approach.
  • Game days: scheduled exercises where the team practises an incident scenario end-to-end, including communication and decision-making.
  • DR drills: planned failover of a full system to the DR site and back. Banks typically run these at least annually per critical system, often more; record timings (detection, decision, failover, verification, failback) as audit evidence.
  • Measure RTO and RPO for real in each drill and compare with targets. The gap is your risk register entry.

Deterministic replicas and poison pills​

Some critical cores are replicated state machines: every replica applies the same ordered log of commands, and because the code is deterministic, every replica ends in the same state. Exchange matching engines work this way (see Ch 13 · Stock Exchange), and so do some ledgers and payment switches. Failover is fast and exact, with one catch: a replica that replays the same input hits the same bug. If command 1042 crashes the leader (say, an unhandled currency code), the standby crashes on 1042 too, and so does every follower that applies it. This is shared fate in software form, and adding replicas does not fix it.

TopologyWho takes overSurvivesRTO / RPO (rough)
In-box hot-warmA warm process on the same host, already consuming the log, starts publishingProcess crashSub-second / 0
Whole-server hot-warmA standby host fed a replicated copy of the logHost or rack lossSeconds / 0 if replication is synchronous, otherwise the lag
Consensus-replicated coreA new leader elected by the majority (Consensus & Raft)Loss of a minority of nodesSeconds / ≈ 0 for committed entries

An exchange is the clearest example: hot-warm engines inside a Raft cluster, aiming for an RTO of seconds and an RPO of ≈ 0. None of the three rows protects against a poison pill, which is why such systems:

  • Validate strictly before a command enters the log.
  • Automate failover only for process and host signals, and stop and page a human if the new leader dies at the same sequence number. Many start with manual failover until drills give them confidence.
  • Give operators a tool to quarantine the bad command by appending a "rejected" or "skip" event, never by editing the log, so the replicas stay identical.
  • Replay recent production logs against every new build before deploying it.

Bank mapping. For a core banking ledger or a payment switch, automate failover for process, host and AZ failures. Make region-level failover, and any "every node dies on the same message" pattern, a declared human decision. A malformed ISO 8583 or ISO 20022 message that crashes the switch's parser on every node should go to a repair queue with a format-error response, not trigger yet another failover.

Data consistency across regions for money​

The hard part of DR for a bank or wallet is not restarting services — it is making sure no money is created, lost or double-spent when sites diverge.

Principles:

  1. Single writer per account. Each account (or customer, or shard) has one home region at a time. Active-active means different accounts are written in different regions — never the same account in two.
  2. Fence the old writer before promoting a new one (revoke its lease, block its network path or credentials, bump an epoch/term number that storage rejects if stale). Split-brain is how money gets double-spent.
  3. Choose replication by RPO: synchronous within region (RPO 0 for AZ failure); for region loss, either accept async RPO above 0 and reconcile, or use a consensus-based distributed database (e.g. Spanner, CockroachDB, YugabyteDB) and pay cross-region latency on every commit.
  4. Idempotency keys must replicate with the transaction (same commit), so a retry in the new region is recognized. Unreplicated keys are part of the RPO window.
  5. Reconcile before reopening: compare the new primary against external sources of truth — switch/scheme settlement files, core banking postings, PSP reports — for the RPO window. Transactions in unknown state are held, not guessed. See Reconciliation & Settlement.
  6. Human in the loop for regional failover of money systems is common: automated failover for AZ-level events, a declared, practised manual decision for region-level events to avoid flapping and split-brain from false alarms.
  7. Degraded modes: during failover, allow balance enquiry and low-value transfers against conservative limits, queue non-urgent payments, and block risky operations until reconciliation completes.

Trade-offs​

OptionStrengthsWeaknessesChoose when
Single AZCheapest, simplestZone failure = outageDev/test, non-critical batch
Multi-AZ, sync replicationRPO 0 for zone loss, modest costNo protection from region-level eventsDefault for production money systems
Multi-region active-passive, asyncSurvives region loss, simpler than active-activeRPO above 0; failover rarely exercisedBank DR site requirement, moderate RTO
Multi-region active-active, partitionedLow RTO, both sites exercised dailyComplex routing, data partitioning, cross-region operationsLarge-scale channels, wallets with home-region accounts
Global consensus databaseRPO 0 across regions, simpler app logicHigher write latency, cost, vendor/tech dependencyGlobal ledgers where latency budget allows
Backups onlyCheap, protects from corruption/ransomwareSlow RTOAlways — in addition to replication

In practice​

A tiny availability calculator helps sanity-check designs in reviews:

package availability

// Serial returns the availability of components that must all work.
func Serial(as ...float64) float64 {
a := 1.0
for _, x := range as {
a *= x
}
return a
}

// Parallel returns the availability of independent redundant components
// where any one is sufficient.
func Parallel(as ...float64) float64 {
fail := 1.0
for _, x := range as {
fail *= 1 - x
}
return 1 - fail
}

// MonthlyDowntimeMinutes converts availability into a 30-day downtime budget.
func MonthlyDowntimeMinutes(a float64) float64 {
return (1 - a) * 30 * 24 * 60
}

Serial(0.9999, 0.9995, Parallel(0.999, 0.999), 0.9995) shows quickly which component dominates your error budget.

Checklist for a critical payment service:

  • Pods spread across ≥ 3 zones with capacity to lose one; PDBs set.
  • Database: synchronous standby in another zone, automated failover tested monthly; PITR enabled; cross-region async replica or backups for DR.
  • Kafka: replication factor 3 across zones, min.insync.replicas=2; cross-region mirroring for DR consumers.
  • Dependencies: timeouts, circuit breakers, fallbacks; secondary PSP or switch link where possible.
  • Runbooks for AZ loss, region loss, data corruption and ransomware; contact tree; decision authority defined.
  • DR drill twice a year with measured RTO/RPO; chaos experiments monthly in staging, selectively in production.
  • Status page and customer communication templates — part of RTO in the customer's eyes.

Common pitfalls​

  • Counting nines without counting dependencies. "Our service is 99.99%" while it calls a 99.9% dependency synchronously.
  • Replication mistaken for backup. Symptom: a bad migration or DELETE replicates to every replica in milliseconds; no PITR, no recovery.
  • Never-tested failover. Symptom: during the real event, the standby has expired certificates, missing secrets, stale config, or not enough capacity.
  • Split-brain. Both sites accept writes after a network partition. Symptom: duplicated or conflicting postings found days later in reconciliation.
  • Shared fate. "Redundant" components share a power feed, a config system, a DNS provider or an IAM dependency. Symptom: both fail together.
  • DR site without capacity. Warm standby sized at 20% with no tested scale-up path. Symptom: failover succeeds, then the DR site collapses under full load.
  • Backups encrypted with keys stored only in the primary site. Symptom: backups exist but cannot be decrypted after the disaster.

Interview angle​

  • When an interviewer says "make it highly available", ask for the target and the RPO/RTO, then compute: "99.99% is ≈ 4 minutes a month; a manual failover cannot meet that, so we need automated multi-AZ failover."
  • Draw the dependency chain and multiply. Point out the weakest link and how to make it redundant or soft.
  • For money, volunteer the hard part: single writer per account, fencing, idempotency keys in the same commit, reconciliation after failover. This is what distinguishes bank-ready candidates.
  • Expect: "What happens to in-flight transactions during failover?", "Would you do active-active for the ledger?", "How often do you test DR and how?", "How do you protect backups from ransomware?"
  • Red flags: "we'll use multi-region active-active" with no conflict strategy; treating replicas as backups; RTO claims without drill evidence; automatic regional failover for a ledger with no fencing.

Self-check​

1. A request passes through four components with availability 99.99%, 99.95%, 99.9% and 99.95%. What is the end-to-end availability and monthly downtime?

0.9999 × 0.9995 × 0.999 × 0.9995 ≈ 0.9979, i.e. ≈ 99.79%. Monthly downtime ≈ 0.0021 × 43,200 min ≈ 90 minutes. The 99.9% component contributes about half of the budget, so it is the first target for redundancy or making the dependency soft.

2. Why does database replication not satisfy a backup requirement?

Replication copies every change — including mistakes, corruptions and malicious deletions — to replicas almost immediately. Backups (with PITR) let you restore to a point before the bad change. You need replication for availability and backups for recoverability, ideally with an immutable off-site copy.

3. Compare pilot light and warm standby in terms of what runs, RTO and cost.

Pilot light keeps only the core data replicating (databases) with application infrastructure defined but switched off or minimal; recovery requires starting and scaling the stack, so RTO is tens of minutes. Warm standby runs the full stack at reduced capacity all the time; recovery means scaling up and redirecting traffic, so RTO is minutes, at higher continuous cost.

4. Scenario: a wallet runs active-passive across two regions with async replication (lag ≈ 2 s). The primary region fails. Walk through a safe failover.

Declare the incident per runbook; fence the old primary (revoke credentials, block traffic, bump the epoch) so it cannot accept writes if it returns. Promote the standby; start in a degraded mode (balance enquiry, low-limit transfers). Identify the RPO window (last ≈ 2 s of unreplicated transactions) and reconcile it against external records (switch, PSP, core) — hold transactions in unknown state. Accept retries only with idempotency keys; keys lost in the window are checked against reconciliation. Reopen fully after reconciliation, then plan failback.

5. Why is active-active hard for a ledger, and how do real systems make it workable?

Two sites accepting writes for the same account can both approve debits against the same balance, creating overdrafts or duplicates, and resolving conflicts after the fact is not acceptable for money. Systems make it workable by partitioning: each account has one home region (single writer), with the other region as standby for it; or by using a consensus-based database that serializes writes across regions at the cost of latency.

6. What should a DR drill measure, and why do banks keep the results?

Detection time, decision time, failover time, data loss (actual RPO), time to verify and reopen (actual RTO), failback time, and issues found (missing secrets, capacity, runbook gaps). Banks keep results as evidence for regulators and auditors that critical systems can be recovered within approved objectives, and to drive remediation.

7. List three ways redundant components can share fate.
  • Same physical dependency: rack, power feed, network switch, AZ.
  • Same logical dependency: config push, DNS provider, certificate, IAM service, secrets store.
  • Same software: a bug or bad deploy hitting all replicas simultaneously (mitigated by staged rollouts and cells).
8. Scenario: your payment switch runs three replicas that apply the same ordered message log. The leader crashes, a follower takes over and crashes 200 ms later at the same sequence number. What is happening, and what do you do?

A poison pill: one input triggers a deterministic bug, so every replica that applies it dies the same way. Another failover would only take down the last node. Stop automatic failover and page the on-call engineer. Identify the message at that sequence number and quarantine it: append a reject or skip event so all replicas stay identical, and return a format error to the sender. Restart the replicas, then fix the bug and replay the log against the fixed build before deploying it. Prevent a repeat with stricter validation before messages enter the log.

🧠 Flashcards0/10 learned · 0 retries

Exercise​

Design HA/DR for an e-wallet with 5 million users, ≈ 800 TPS peak, RPO 0 for AZ failure and ≤ 5 s for region failure, RTO 15 minutes for region failure:

  1. Draw the deployment across two regions and three AZs each (Mermaid).
  2. Compute expected availability of the payment path including the external switch; identify the weakest link.
  3. Choose replication modes for the ledger DB, Kafka and Redis; justify each against the RPO.
  4. Write the regional failover runbook: detection, decision authority, fencing, promotion, degraded mode, reconciliation, reopening, failback.
  5. Define three chaos experiments and one DR drill with success criteria.
  6. Estimate the monthly cost difference between warm standby and active-active (rough, with assumptions stated).

Done when: every step in the runbook has an owner and a time estimate that sums to under 15 minutes, and you can explain exactly what happens to a transfer that was in flight when the region failed.

Further reading​

  • Site Reliability Engineering and The Site Reliability Workbook — Google (O'Reilly, 2016/2018). Availability, SLOs, managing risk.
  • AWS whitepaper, Disaster Recovery of Workloads on AWS: Recovery in the Cloud — the four DR strategies.
  • Chaos Engineering: System Resiliency in Practice — Casey Rosenthal & Nora Jones (O'Reilly, 2020).
  • Principles of Chaos Engineering (principlesofchaos.org).
  • Designing Data-Intensive Applications — Martin Kleppmann. Replication, failover and split-brain.
  • Release It! (2nd ed.) — Michael Nygard (2018). Stability patterns and anti-patterns.
Finished this page?

Do the self-check first. Marking it complete schedules spaced reviews (1, 3, 7, 14, 30… days).