Fault Tolerance, High Availability, and Disaster Recovery Questions
Keeping a system serving despite failure, from code-level resilience to infrastructure-level recovery: circuit breakers, retries with backoff and jitter, timeouts, bulkheads, graceful degradation, and preventing cascading failures, alongside redundancy, failover (active-active versus active-passive), RPO and RTO objectives, backup and restore, and multi-region failover. Covers dependency-failure isolation, chaos engineering to validate resilience, failure-mode analysis, designing to nines of availability, cost-versus-availability tradeoffs, and recovery runbooks. Spans both the patterns that isolate partial failure and the disaster-recovery planning that restores a business-critical system after a major outage.
Walk through the common replication topologies, single-leader, multi-leader, and quorum-based, and how each affects consistency, latency, and availability.
Sample Answer
Direct answer: Single-leader replication routes all writes through one node and copies them out to followers, giving strong consistency on the leader but a failover gap if it dies. Multi-leader replication lets several nodes accept writes independently and merge them later, trading consistency for local write availability. Quorum-based replication has no fixed leader; reads and writes each require acknowledgment from a configurable subset of replicas, and the overlap between those subsets is what determines the consistency guarantee.
Structured elaboration
| Topology | Consistency | Write latency | Availability under partition |
|---|---|---|---|
| Single-leader | Strong on the leader; followers can lag (eventual, unless reads are forced to the leader) | Low (single write path, no coordination) | Writes unavailable if leader partitioned away until failover completes; reads can continue from followers |
| Multi-leader | Eventual; requires conflict resolution (last-write-wins, CRDTs, app-level merge) | Low locally at each leader | High: each site keeps accepting local writes during a partition, at the cost of divergence to reconcile later |
| Quorum-based | Tunable, from eventual to strong, depending on read/write quorum sizes | Higher (must wait for multiple acknowledgments, not just one) | Survives a minority of node failures without going unavailable; a true majority-losing partition halts progress |
The quorum math that determines consistency: for N replicas, a write quorum of W nodes and a read quorum of R nodes, the system guarantees a read overlaps with the most recent write whenever
W+R>NThis is a direct pigeonhole argument: if W and R are subsets of the same N-replica set and ∣W∣+∣R∣>N, they cannot be disjoint (two disjoint subsets can sum to at most N elements total), so they must share at least one replica, and that shared replica has both the latest write and is included in the read.
Worked example with N=3:
- W=2,R=2: W+R=4>3, so every read quorum is guaranteed to overlap every write quorum by at least one replica. This gives strong (read-your-writes) consistency, at the cost of needing acknowledgment from 2 of 3 replicas on both reads and writes.
- W=1,R=1: W+R=2≤3, no overlap is guaranteed. A write can land on replica A while a read is served entirely from replica B, missing it. This is fast (single-replica round trip) but only eventually consistent.
Trade-offs & pitfalls
- Single-leader is the simplest to reason about and the default choice unless you have a specific reason not to use it; its main weakness is the failover window (detecting the leader is gone and safely promoting a replacement), not steady-state operation.
- Multi-leader avoids that failover gap for writes but pushes complexity into conflict resolution; it's the right choice specifically when you need low-latency local writes at multiple sites and can tolerate (or algorithmically resolve) concurrent edits, not as a general-purpose upgrade over single-leader.
- Quorum systems let you dial the W/R trade-off per workload (e.g., W=1 for a write-heavy, tolerant-of-staleness workload; W=N for a read-heavy workload that wants every read to be a single, fast, guaranteed-fresh replica read), but that tunability is also a footgun: teams often ship with W+R≤N by default (e.g., both set to 1 for speed) without realizing they've silently given up the consistency guarantee they assumed they had.
- A common wrong turn: treating "quorum-based" as automatically stronger than single-leader. With W+R≤N it is weaker, not stronger, than a single-leader system with synchronous replication to at least one follower.
Data residency requirements mean you can't freely replicate a customer's data across borders. Walk through how you'd design a multi-region architecture that still gives you reasonable availability within those constraints.
Sample Answer
Direct answer
Default to regional partitioning: keep each country or region's primary data store entirely inside that region's boundary, route each user's traffic to their home region, and use a lightweight global control plane (metadata, feature flags, non-personal configuration) that's free to replicate everywhere because it doesn't contain the restricted data. Availability within a residency-constrained region then comes from the same tools you'd use anywhere: redundant replicas and a fast local failover path, just constrained to stay inside the boundary rather than failing over to a healthy replica in a different country.
Design options and their trade-offs
| Option | How it works | Availability profile | When it fits |
|---|---|---|---|
| Regional partitioning (baseline) | Separate DB clusters and object stores per region; requests route to the local region only | Availability depends entirely on in-region redundancy (multi-AZ within the region); no cross-border failover possible by design | Default choice: strongest compliance guarantee, simplest to audit, and the right starting point before considering exceptions |
| Consent-based replication | Per-record consent flag; consenting users' data replicates to a central region for global features (analytics, search) | Same as regional partitioning for non-consenting users; consenting users gain cross-region availability for the replicated subset | Global features (cross-region search, aggregate analytics) that need some data outside the home region, and where consent is a legally sufficient basis |
| Dual writes with residency filters | App writes to the local primary and, for allowed fields only, to a remote replica via residency-aware middleware that filters or pseudonymizes before crossing the border | Higher availability for the allowed subset (near real-time cross-border access) but adds write-path complexity and a second consistency boundary to reason about | Narrow fields that are provably safe to replicate (pseudonymized identifiers, non-PII aggregates) where the latency or availability win justifies the added complexity |
| Contractual and technical mitigations | Data processing agreements, standard contractual clauses, and customer-managed encryption keys stored in-country, used instead of full architectural separation | Doesn't change the underlying availability profile; it's a legal and access-control layer on top of whichever architecture you chose | When full technical separation is genuinely impractical and legal has validated the mitigation is sufficient for the jurisdiction in question; not a substitute for architecture, a supplement to it |
Achieving reasonable availability inside the constraint
Once data can't leave a region, availability has to come from redundancy that stays inside the boundary: multi-AZ deployment within the region (the residency constraint is about crossing the country border, not about running a single instance), automated in-region failover with the same detection-and-promotion mechanics as any single-region HA design, and continuous backups stored within the same jurisdiction (a backup that lands in a different country to satisfy some other requirement, like disaster-recovery diversity, would itself violate residency unless that specific transfer is legally permitted). The trade-off to be explicit about with stakeholders: a residency-constrained region cannot achieve the same worst-case availability ceiling as a design free to fail over anywhere on Earth, because the blast radius of "this entire region's infrastructure provider has an outage" can't be absorbed by routing to a healthy region elsewhere. That's a real, unavoidable cost of the constraint, not an engineering gap to be closed.
Worked example: one customer's data, traced through the design
Take a specific case: a customer in Germany whose profile (name, address, government ID fields) is subject to EU residency rules. Under regional partitioning, that profile lives entirely in an eu-central data store, and the German customer's traffic is routed only to eu-central; a customer-service agent or batch job in us-east has no path to that record at all, by design, and if eu-central has an outage, availability for that customer depends only on eu-central's own in-region redundancy, not on any other region. Now add one narrow exception under dual writes with residency filters: the product wants a global leaderboard that ranks customers by loyalty tier across all regions. The app writes the full profile to eu-central as always, and separately, the residency-aware middleware extracts and pseudonymizes just one field, a loyalty-tier flag ("gold", "silver", "bronze", with no name, address, or ID attached), and replicates only that pseudonymized value to us-east so the global leaderboard can read it. Every other field (name, address, government ID) never crosses the border; only that one pseudonymized, non-identifying field does, which is exactly the kind of narrow, provably-safe field this option is meant for. If the filtering logic had a bug that let the raw name field slip through in that same replication path, that would be a real data-protection incident, not just a defect, which is why this option carries the most scrutiny of the four.
Trade-offs & pitfalls
The most common mistake is treating residency as a per-field flag applied after the fact rather than a first-class part of the data model from the start; retrofitting field-level residency onto a schema that was built assuming free replication usually means re-auditing every existing replication path and every downstream consumer (analytics jobs, search indexes, caches) that may have already copied restricted data outside the boundary. Consent-based replication is attractive because it enables global features, but it pushes real operational complexity onto consent-state management: a user who revokes consent after their data has already replicated needs a defined, auditable deletion path in every region it reached, not just a flag flip in the primary. Dual writes with residency filters are the riskiest option operationally, because the filtering logic itself becomes a compliance-critical piece of code; a bug that lets one unfiltered field slip through the residency-aware middleware is a real data-protection incident, not just a bug, so this option deserves the most scrutiny and testing of the four and should generally be adopted last, only for fields where the business case clearly justifies the added risk.
Design a retry strategy with exponential backoff and jitter for calls to a downstream dependency that's struggling. Walk through why jitter matters, and how you'd make sure your retries don't make the dependency's problem worse when it starts recovering.
Sample Answer
Plain exponential backoff (double the delay after each failed attempt) reduces load on a struggling dependency over time, but it has a hidden flaw: if many clients failed at roughly the same moment (which is exactly what happens when the dependency itself goes down), they all compute the same delay sequence and retry in lockstep, so the "backoff" just delays the same synchronized spike instead of spreading it out. Jitter fixes that by randomizing the delay so clients that failed together don't retry together.
Jitter strategies compared
| Strategy | Delay formula | Behavior |
|---|---|---|
| No jitter | delay=base×2attempt | Deterministic; every client that failed together retries together, recreating the spike at each step |
| Full jitter | delay=random(0, base×2attempt) | Maximum spread; delay can be anywhere from 0 up to the cap, so retries are smeared thinly across the whole window |
| Equal jitter | delay=2cap+random(0, 2cap) | Keeps a guaranteed minimum delay (never retries immediately) while still spreading the upper half randomly |
| Decorrelated jitter | delay=random(base, previous delay×3) | Grows the delay based on the client's own previous delay rather than a fixed exponential schedule, avoiding a hard cap while still spreading load |
Worked example: how much jitter actually reduces the spike
Pin a concrete scenario: 1000 clients failed at the same moment, base delay = 1 second, and this is their 3rd retry attempt (attempt = 3), so the backoff cap is:
cap=1s×23=8 secondsWithout jitter: every one of the 1000 clients computes the identical 8-second delay and retries at exactly the same instant, a spike of 1000 concurrent requests hitting the dependency in one moment, right as it may just be starting to recover.
With full jitter, each client independently draws a delay uniformly from [0,8] seconds. Dividing that 8-second window into 100 ms buckets gives 8000/100=80 buckets, and under a uniform distribution the expected number of clients landing in any single bucket is:
801000=12.5 requests per 100ms bucketThat's a peak-to-average reduction factor of 1000/12.5=80× under this modeling assumption (uniform, independent draws), turning one instantaneous spike of 1000 into a smooth trickle of roughly 12-13 requests every 100 ms across the full 8-second window, which a recovering dependency can absorb where a single 1000-request spike would knock it back down.
Why retries shouldn't make recovery worse
Jitter alone doesn't prevent the retry storm from getting worse over time if attempts aren't capped: a client that keeps failing and keeps retrying at base×2attempt forever will eventually be sending requests at a cap so large it's functionally giving up, or, worse, if the cap is bounded, converges back to a steady drumbeat of load that never lets the dependency fully recover. The fix is a hard cap on both the maximum delay and the maximum number of attempts, plus honoring any explicit signal the server provides (a Retry-After header or a 429/503 status) as authoritative over the client's own backoff schedule, since the server is in the best position to know its own recovery state.
Trade-offs and pitfalls
Full jitter maximizes spread but means some unlucky clients draw a near-zero delay and retry almost immediately, which is fine in aggregate (that's still only ~12-13 requests per 100ms bucket in the example above) but means full jitter alone doesn't guarantee a minimum backoff for any individual client; equal jitter trades some of that spread for a guaranteed floor, useful when even a small number of near-instant retries is unacceptable. A pitfall specific to mobile or otherwise unreliable-network clients: retries are only safe to jitter and reattempt if the underlying operation is idempotent (repeating it produces the same end result as doing it once, so a duplicate attempt is harmless), a non-idempotent submit (a payment, an order) retried after a client-side timeout can double-execute if the server had actually processed the first attempt and just failed to deliver the response, so the fix belongs on the server (idempotency keys deduping identical requests) not just in the client's backoff logic, jitter reduces load, it does not make an unsafe retry safe.
Your write region goes down for a couple of hours but your read regions are healthy. Design a graceful degradation plan: what stays available in read-only mode, what fails outright, and how do you communicate the degraded state to users?
Sample Answer
Direct answer
Keep serving reads from the healthy read regions immediately and unconditionally, since they don't depend on the write region at all; reject writes that require strong consistency or exactly-once guarantees outright with a clear error rather than pretending to accept them; and for writes that tolerate eventual consistency, queue them locally and durably so nothing is lost, then replay the queue once the write region recovers. The one rule that should never be violated is silently accepting a write and losing it: every write path is either "accepted and durably queued for later replay" or "rejected immediately," never "accepted and quietly dropped."
Architecture
Writes accepted by the anchor leader flow out to every read region as a CDC stream (change data capture: a continuous feed of every row-level change, read off the leader's own write log and replayed onto each replica), which is what keeps the read replicas caught up during normal operation, shown as the CDC node in the diagram below.
flowchart TD
CLIENT[Clients worldwide] --> RA[Region A read replica]
CLIENT --> RB[Region B read replica]
CLIENT --> RC[Region C read replica]
RA --> FWD[Write forwarder]
RB --> FWD
RC --> FWD
FWD --> LEADER[Anchor write leader, sharded by key range]
LEADER --> CDC[CDC stream]
CDC --> RA
CDC --> RB
CDC --> RC
When the write region (the anchor leader) goes down, the forwarder can no longer reach it. That's the trigger for the degradation workflow below; everything downstream of "detect the write region is unreachable" is about what each request type does next.
What stays available, what fails, what queues
| Request type | Behavior during the outage | Why |
|---|---|---|
| Reads (any kind) | Served normally from the nearest healthy read replica | Reads never depended on the write region; replication lag from before the outage started is the only staleness, and it stops growing once the write region is down (no new writes are landing to replicate) |
| Critical writes (billing, auth changes, anything needing exactly-once) | Rejected immediately with a 503 and a Retry-After header, structured as {mode: "read-only", eta: ..., writeAllowed: false} | These require strong consistency; queuing and replaying them risks double-charging or auth-state corruption, so refusing cleanly is safer than accepting and reconciling later |
| Non-critical writes (comments, drafts, "last viewed" timestamps) | Accepted at the edge, appended to a durable, region-local, idempotency-keyed queue, and the client gets a 202 Accepted with a queue ID | These tolerate eventual consistency, so queuing preserves the user's action without requiring the write region to be up right now |
| Complex cross-region features (distributed transactions, long multi-step jobs) | Disabled via feature flag for the duration of the outage | These need coordination that the write region's absence makes impossible to do correctly; a degraded system telling the user "this feature is temporarily unavailable" is better than a feature that silently does the wrong thing |
Communicating the degraded state
- API-level: every write endpoint that's disabled returns a structured error body, not a bare 503, so client applications can distinguish "the write region is down" from a generic server error and render an appropriate message instead of a raw failure.
- UX-level: a persistent banner ("Changes are temporarily disabled; you can still view everything. We'll apply queued updates once service resumes.") rather than silent failures scattered across individual actions, and per-action status for anything queued ("Saved locally, will publish when service resumes") so users aren't left wondering whether their action actually did anything.
- Ops-level: a status page update and, for major customers, proactive notification with an ETA, since 2 hours of read-only mode is the kind of thing enterprise customers expect to hear about before they notice it themselves.
Reconciliation when the writer returns
Queued writes are replayed in the order they were queued, using the idempotency key each write was tagged with to detect and skip duplicates (a client that retried a queued write multiple times during the outage shouldn't apply multiple times on replay). Conflict handling depends on the data type: commutative operations (counters, like counts) merge deterministically with no ambiguity; simple last-write-wins fields use the write's original logical timestamp, not the replay time, so a user's genuinely earlier edit doesn't overwrite a genuinely later one just because it replayed second; and content edits with a real risk of conflicting concurrent changes (two people editing the same document) get surfaced to the user as a merge conflict rather than silently resolved, because a silent wrong resolution is worse than asking.
Trade-offs & pitfalls
The scope of what gets classified "critical" versus "queueable" is the actual design decision here, and it's easy to get wrong in both directions: classifying too much as critical means the read-only window feels far more restrictive than it needs to be, while classifying too much as queueable risks a replay-time conflict resolution mess for data where "eventually consistent" was never actually an acceptable property. A related pitfall is bounding the queue: an unbounded local write queue during a multi-hour outage can grow large enough that the replay itself becomes a second incident (a burst of stale updates hitting the recovered write region all at once), so the queue needs both a size cap (reject new non-critical writes past a threshold, same as critical ones) and a TTL, with the two-hour outage in this scenario sized against realistic write volume before committing to "queue everything non-critical" as the policy. The same read-only degradation shape applies whether the thing behind the write region is a recommendation service, an image-preview pipeline, a personalization engine, or an analytics dashboard. In every case the same triage question decides the design: does this write need to be right immediately, or can it be right eventually, and only the answer to that question, not the specific feature, determines whether it queues or rejects.
Two regions running asynchronous replication get network-partitioned, and both keep accepting writes. When the partition heals, how do you detect the divergence and reconcile the conflicting writes?
Sample Answer
Direct answer
This is the multi-master conflict case: because replication was asynchronous and both regions kept accepting writes, there are now two divergent histories that both look locally valid. Detecting divergence means comparing state between regions, via hashes or version metadata, once connectivity returns, not waiting for a customer to report bad data. Reconciling means classifying each conflict by whether it's safely auto-mergeable or needs a compensating action; financial and other invariant-sensitive writes should never be silently overwritten.
Structured elaboration
Detecting divergence. Attach causal metadata to every write, a vector clock (an array with one counter per region, incremented only when that region processes a write, so comparing two vectors shows whether one write causally happened after the other, every counter at least as high, or whether the two happened independently) or at minimum a per-region monotonic sequence number plus timestamp, so that on reconnect two versions of the same key can be compared to tell, mathematically, whether one supersedes the other or whether they are genuinely concurrent, meaning both sides wrote independently during the partition.
sequenceDiagram
participant RegionA
participant RegionB
participant Reconciler
Note over RegionA,RegionB: Partition: both regions accept writes independently
RegionA->>RegionA: Write key X, vector clock [A:5,B:3]
RegionB->>RegionB: Write key X, vector clock [A:4,B:4]
Note over RegionA,RegionB: Partition heals
Reconciler->>RegionA: Fetch change log with vector clocks
Reconciler->>RegionB: Fetch change log with vector clocks
Reconciler->>Reconciler: Compare vector clocks, classify conflicts
Reconciler->>Reconciler: Auto-merge commutative writes
Reconciler->>Reconciler: Apply compensating transaction for invariant conflicts
Reconciler->>RegionA: Apply resolved state
Reconciler->>RegionB: Apply resolved state
Reconciling. Not every conflict resolves the same way:
| Conflict type | Resolution |
|---|---|
| Non-overlapping keys, touched on only one side | Trivial union merge, no real conflict |
| Commutative or CRDT-safe operations (counter increment, set-add). CRDT: conflict-free replicated data type, a data structure designed so concurrent updates always merge to the same result automatically, no coordination needed | Merge automatically, order doesn't matter |
| Same-field conflicting writes with no safe merge rule | Deterministic policy where business semantics allow it, such as latest-timestamp-wins, logged to a resolved-log for audit |
| Financial or invariant-sensitive conflicts | Never blind-overwrite; apply a compensating transaction, an explicit correcting entry linked to the original, so history stays auditable and reversible |
Worked example: detecting a real conflict with vector clocks
Two regions independently update the same key, "user:42.email," during the partition. Region A's write carries vector clock VA=[A:5,B:3], Region B's write carries VB=[A:4,B:4].
A vector clock V1 dominates V2, meaning V1 happened after V2 and can safely overwrite it, only if every component of V1 is greater than or equal to the corresponding component of V2, with at least one strictly greater. Checking:
VA[A]=5>VB[A]=4butVA[B]=3<VB[B]=4Neither vector dominates the other, A leads on its own component, B leads on its own, so this is a genuine concurrent conflict, not a case where one write simply supersedes the other, and it must go through the merge policy rather than being resolved by picking the higher-looking clock.
Worked example: scoping the reconciliation workload
Assume the partition lasted 10 minutes, each region accepted 150 writes/sec across a 5-million-key space:
n1=n2=150×600=90,000 writes per side E[colliding keys]=Nn1×n2=5,000,00090,000×90,000=5,000,0008,100,000,000=1,620Of 180,000 total writes across both sides, an estimated 1,620 keys, 0.9%, are true conflicts needing the merge policy; the rest merge by simple union. Sizing the reconciliation pipeline, and any manual-review queue, around this number, not around all writes during the partition, is what keeps the process fast.
Trade-offs & pitfalls
- Silently applying last-writer-wins to every conflict is the most common shortcut, and it's the wrong default for anything with a business invariant, balances, inventory counts: it loses data without a trace and without anyone knowing which write "won."
- Scanning the entire keyspace for divergence, instead of the range touched during the outage window, wastes time and delays recovery.
- A merge policy that isn't tested against the conflict-type classification before the incident means the policy is being designed live, under pressure, which is when mistakes compound.
- Compensating transactions must themselves be idempotent and auditable; a reconciliation "fix" that isn't traceable back to the original conflicting writes creates a second, harder-to-debug data quality problem.
Unlock Full Question Bank
Get access to all Fault Tolerance, High Availability, and Disaster Recovery interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.