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.
A circuit breaker is flapping: it trips every time the error rate blips to 5% for about a minute, then closes, then trips again a few minutes later. Walk through why this is probably happening and what you'd change about the breaker's configuration to fix it.
Sample Answer
Direct answer
Flapping like this, tripping on a brief 1-minute blip and closing again a few minutes later, is almost always caused by an evaluation window that's too short and a threshold that's checked as a raw instantaneous rate instead of a smoothed one, with no hysteresis between the open and closed conditions. The fix is to require the elevated error rate to persist for a sustained period before tripping (smoothing or a minimum-duration requirement), and to require a different, lower threshold sustained for a while before closing again (hysteresis), so the breaker doesn't oscillate around a single threshold value that noisy traffic keeps crossing in both directions.
Why this specific symptom happens
A breaker that evaluates a short window (say a single 10 to 30 second bucket) against a fixed absolute threshold (say 3 to 5 percent) will trip the instant any one bucket crosses that number, regardless of whether the elevated rate is a real sustained problem or a one-minute noise blip from a handful of slow requests. Once it trips and the cooldown expires, it closes again because the very next window looks normal, and then trips again a few minutes later the next time normal traffic variance happens to produce another short blip above the same threshold. The breaker isn't wrong that error rate crossed 5 percent, it's wrong that a single brief crossing is sufficient evidence of a real outage worth failing traffic away from a service that's actually healthy most of the time.
Fixes, in order of how much they change behavior
1. Smoothing the signal. Replace the raw per-window rate with an exponential moving average (EMA), so a short spike gets damped rather than immediately crossing the threshold:
EMAt=αxt+(1−α)EMAt−1With α=0.2, a baseline error rate of 1 percent, and a 1-minute burst of 5 percent sampled every 10 seconds (6 samples):
EMA1EMA2EMA3EMA4EMA5EMA6=0.2(0.05)+0.8(0.01)=0.018=0.2(0.05)+0.8(0.018)=0.0244=0.2(0.05)+0.8(0.0244)=0.02952=0.2(0.05)+0.8(0.02952)=0.033616=0.2(0.05)+0.8(0.033616)=0.036893=0.2(0.05)+0.8(0.036893)=0.039514Against a 3.5 percent trip threshold, the raw signal crosses it on sample 1 (5 percent, instantly), but the EMA doesn't cross 3.5 percent until sample 5, roughly 50 seconds into the burst. That 50-second delay is the point: it means a true 1-minute-and-done blip barely trips the breaker at all (it only just crosses right as the burst is ending), while a genuinely sustained failure keeps climbing well past threshold and trips decisively.
2. Hysteresis between open and close conditions. A breaker actually cycles through three states: closed (normal, calls flow through), open (tripped, calls are rejected outright without even trying the dependency), and half-open (a brief trial period after opening where a small number of requests are deliberately let through to test whether the dependency has actually recovered) before it's allowed back to closed. Use a different, lower threshold to close than to open, and require it sustained for a minimum duration, not a single good sample: for example, trip open at EMA > 3.5 percent sustained for 2 evaluation periods, but only close from half-open back to closed once EMA stays below 2 percent (not 3.5 percent) for 2 consecutive periods. This asymmetry is what actually stops the flap-then-immediately-reopen cycle, because closing requires meaningfully cleaner traffic than the level that caused the trip, not just traffic that's dipped fractionally under the same number.
3. Minimum sample size. Require a floor on request volume before evaluating the rate at all (for example at least 200 requests in the window); at low traffic volumes a handful of failed requests can swing the percentage wildly even though the absolute failure count is tiny, and no smoothing scheme fixes a rate computed from too small a denominator.
4. Gradual re-entry. When the breaker closes, ramp traffic back in (5 percent, then 20 percent, then full) rather than snapping straight back to 100 percent, so a dependency that's only marginally recovered doesn't get immediately re-tripped by the full traffic load the instant it reopens.
Trade-offs & pitfalls
Every one of these fixes trades detection speed for stability: a smoothed, hysteresis-gated breaker takes longer to trip on a real outage than a naive instant-threshold one, which is the correct trade for a dependency where false trips are expensive (unnecessary failover, alert fatigue), but the wrong trade for something where even a few seconds of cascading failure is unacceptable, so the constants here (alpha, thresholds, minimum duration) should be tuned against the actual cost asymmetry for that specific dependency, not copied from another service. A subtler pitfall is that smoothing and retries interact: if callers retry failed requests, each retry counts as an additional data point in the error-rate window, so a retry storm during a real degraded period can itself inflate the EMA further and trip the breaker faster than the underlying failure rate alone would justify, which is usually the desired outcome (retries are evidence something is actually wrong) but is worth knowing explicitly rather than discovering by surprise. Validating any change to these constants should happen by replaying real historical traffic traces (including past incidents and known-noisy periods) through the new policy offline, comparing false-trip rate and time-to-detect-real-outage against the old policy, before rolling the new thresholds out as a canary.
You operate a microservices ecosystem where services have different RPO requirements: user profiles need 30 seconds, payment transactions need zero, analytics can tolerate 24 hours. Design a cross-region replication and backup strategy that meets each service's RPO without over-engineering the ones that don't need it.
Sample Answer
Direct answer
Don't pick one replication strategy for the whole system, match the mechanism to each service's stated RPO (recovery point objective: the maximum amount of data, measured in time since the last durable copy, the service can afford to lose): synchronous or quorum replication for the zero-RPO service, change-data-capture streaming for the near-real-time service, and periodic snapshotting for the tolerant one. Then sequence recovery in dependency order so a service isn't restored before the upstream it depends on is back. Over-engineering shows up as spending synchronous-replication effort on the analytics service that only ever needed a daily snapshot.
Structured elaboration
| Service | RPO target | Mechanism | Why this and not stronger or weaker |
|---|---|---|---|
| Payment transactions | 0 | Synchronous or quorum-committed write across regions | Anything weaker risks losing a committed financial transaction, the one class of loss with real legal and trust cost |
| User profiles | 30 seconds | CDC streaming to a regional replica | Full synchronous replication isn't justified by a 30s target and would add unnecessary write latency to every update; async streaming with monitored lag comfortably meets it |
| Analytics | 24 hours | Periodic snapshot to replicated object storage | Synchronous or streaming replication here is pure over-engineering, batch analytics has no user-facing latency requirement |
Recovery ordering. Sequence recovery by dependency and criticality, not by which service happens to come back online first: promote the payments store first, the highest-integrity requirement and smallest tolerance for being wrong, verify it, then catch up and promote the profile replica, verify it, then resume analytics last, since nothing else depends on analytics being current.
flowchart TD
F[Region A failure detected] --> P[1. Promote payments quorum replica, fence old leader]
P --> V1{Verify: writes accepted, balances reconciled}
V1 --> U[2. Drain CDC backlog, promote profile replica]
U --> V2{Verify: profile lag = 0}
V2 --> A[3. Resume analytics batch jobs from last snapshot]
A --> V3{Verify: end-to-end smoke tests pass}
Worked example: setting the CDC alerting margin for the 30-second service
Assume the profile CDC pipeline runs with a measured steady-state lag of 8 seconds, a baseline from monitoring. The RPO budget is 30 seconds, so the available headroom before breaching the target is:
30−8=22 secondsSet the alert threshold partway through that headroom, not right at the limit, so operators have real reaction time before an actual breach:
8+222=19 seconds≈20 seconds (alert threshold)That leaves roughly 10 seconds of buffer between the alert firing and the RPO actually being breached, enough time for an on-call engineer to begin triage before the commitment is broken, not just a number picked because it's below 30.
Worked example: sizing the payments quorum's commit-latency cost
Payments run a 3-region majority quorum, 2 of 3 acks required to commit. Nearer replica round trip 20ms, farther replica 45ms. Since only one remote ack is needed alongside local:
commit latency=local write+min(20,45)=local write+20 msThis is the explicit, quantified latency tax paid on every payments write to guarantee RPO=0, weighed against the alternative, accepting some RPO on payments, which the requirement already ruled out.
Worked example: analytics snapshot cadence margin
The RPO target is 24 hours; a snapshot cadence set exactly at 24 hours leaves zero margin if a single run is delayed or fails. Running at a 20-hour cadence instead:
24−20=4 hours of buffer against a missed or delayed run still landing inside the 24-hour RPOTrade-offs & pitfalls
- Recovering services in the wrong order, for example bringing user-facing profile reads back before payments is verified consistent, can let the system present data that later needs correcting once the higher-priority service catches up; sequence by criticality and dependency, not convenience.
- Setting the CDC alert threshold exactly at the RPO limit gives operators zero reaction time; build in the margin explicitly, as in the worked example.
- A cadence set exactly equal to an RPO target, as in the naive 24-hour snapshot case, has no tolerance for a single missed run; always leave margin.
- Applying the payments-grade synchronous mechanism to the profile or analytics services because it's "the safest option" is not safety, it's unnecessary latency and cost on writes that never needed that guarantee. Over-engineering the services that can comfortably tolerate a higher RPO, namely profile (30 seconds) and analytics (24 hours), by giving them payments-grade guarantees they don't need is exactly the failure mode this question is testing for.
Explain active-active versus active-passive architecture. For each, walk through the typical failover behavior, what it takes to detect a failure, and when you'd choose one over the other.
Sample Answer
Active-active runs all nodes or regions serving live traffic at the same time, so failover is mostly a routing problem: stop sending traffic to the unhealthy node. Active-passive keeps one side idle (or partially warmed) as a standby, so failover is a promotion problem: detect the primary is down, make the standby the new primary, then redirect traffic to it. That difference in what has to happen during failover is what drives everything else: recovery speed (RTO, recovery time objective: how long it takes to restore service after a failure), data-consistency risk (RPO, recovery point objective: how much data, measured in time, you could lose in a failure), and cost.
Comparing the two
| Dimension | Active-active | Active-passive |
|---|---|---|
| What's serving traffic | All nodes/regions, concurrently | Only the primary; standby is idle or warm |
| Failure detection | Health checks per node feed a load balancer or GSLB (Global Server Load Balancer: a DNS-based load balancer that routes traffic across regions, not just across servers in one place), which simply stops routing to the failed one | Health checks must trigger an explicit promotion decision, usually with a consensus/quorum step to avoid promoting during a false alarm |
| What "failover" does | Reroute traffic; no state transition needed | Promote replica to primary, update routing (DNS or LB config), then reroute traffic |
| Typical RPO | Near-zero if writes are synchronously replicated or conflict-resolved; otherwise bounded by replication lag | Near-zero with a synchronous standby, up to minutes with an async one |
| Consistency risk | Needs conflict resolution or partitioned ownership if writes happen on both sides (dual-writer problem) | Simpler: single writer at any point in time, no conflict resolution needed |
| Cost/complexity | Higher: full capacity running everywhere, plus distributed-write tooling | Lower: standby can run at reduced capacity (or be provisioned only at failover time) |
| Best fit | Latency-sensitive, globally distributed traffic; teams that can invest in multi-writer data patterns | Systems needing a single source of truth for writes (most transactional relational databases); cost-sensitive setups |
Worked example: deriving RTO for each
Pin the same detection policy to both: a health check runs every 5 seconds, and 3 consecutive failures are required before the system acts (15 seconds to declare a node down; this avoids reacting to a single dropped probe).
Active-active RTO: once the node is declared down, the load balancer or GSLB removes it from rotation immediately (no promotion step). If we assume that rotation update takes about 5 seconds to propagate to all edge/LB nodes:
RTOactive-active≈15s (detect)+5s (reroute)=20 secondsActive-passive RTO: the same 15 seconds to detect, plus a promotion step (electing the standby, replaying any un-applied log entries, opening it for writes, say 20 seconds for a warm standby with low replication lag) plus DNS or routing propagation (assume a low TTL of 30 seconds, and worst case the full TTL has to expire before every client picks up the change):
RTOactive-passive≈15s (detect)+20s (promote)+30s (routing propagation)=65 secondsUnder these pinned assumptions, active-active recovers about 3x faster, entirely because it skips the promotion step, and that gap only grows if the standby is cold rather than warm (add provisioning time) or if the routing layer is DNS with a high TTL instead of a fast health-checked LB.
Trade-offs and pitfalls
Active-active's speed advantage is real but not free: the moment two regions can both accept writes to the same record, you have a distributed-write problem, and skipping it (assuming replication will "just" reconcile) is the most common wrong turn. It needs either a conflict-resolution strategy (last-write-wins with vector clocks, CRDTs) or partitioned ownership (each region owns a disjoint key range) to avoid silently losing or corrupting data during a partition. Active-passive's failure mode is different: over-eager health checks or a flapping network link can trigger a premature promotion while the old primary is still technically reachable by some clients, producing two nodes that both believe they're primary (split-brain), which is why production active-passive systems add fencing (forcibly cutting off the old primary's access to shared storage) on top of the detection logic above, not just a timer. The same trade-off shows up outside a classic web/DB stack too: failing over an ML-serving fleet is closer to active-active in spirit (multiple replicas of the same model serving concurrently, so losing one just drops capacity) unless the model itself is being hot-swapped, in which case the promotion-style risk (serving from a half-loaded or stale model version) reappears.
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.
For availability targets of 99.9%, 99.99%, and 99.999%, calculate the allowed downtime per year and per month for each. Then walk through what architectural changes actually get you from one tier to the next.
Sample Answer
Direct answer: Availability is the fraction of time a system is usable, and "N nines" is shorthand for how close that fraction is to 100%. Going from 99.9% to 99.99% to 99.999% shrinks allowed downtime by roughly 10x at each step, and each step also costs roughly an order of magnitude more in engineering and infrastructure, because you're eliminating an entire category of failure (single-host, then single-zone, then single-region) rather than just adding more of the same redundancy.
Structured elaboration
Allowed downtime per year is derived from the availability target directly:
downtimeyear=(1−A)×8760 hourswhere 8760 is the number of hours in a 365-day year (24 x 365), and per-month downtime uses 730 hours (8760 / 12):
downtimemonth=(1−A)×730×60 minutesPlugging in each target:
| Availability | Allowed downtime / year | Allowed downtime / month |
|---|---|---|
| 99.9% ("three nines") | (1−0.999)×8760=8.76 hours -> 8h 45m 36s | (1−0.999)×730×60=43.8 min |
| 99.99% ("four nines") | (1−0.9999)×8760=0.876 hours -> 52m 34s | (1−0.9999)×730×60=4.38 min |
| 99.999% ("five nines") | (1−0.99999)×8760=0.0876 hours -> 5m 15s | (1−0.99999)×730×60=0.438 min -> 26s |
Each jump divides allowed downtime by exactly 10, because each availability target divides (1−A) by 10.
What actually changes architecturally between tiers
- 99.9% -> 99.99%: eliminate single points of failure inside one facility. Multi-AZ deployment, N+1 redundancy (one extra standby unit beyond what's strictly needed to handle normal load, so a single failure doesn't drop capacity below what's required) on stateful components (load balancers, databases with a standby replica), automated health-check-driven failover, and a real on-call rotation with paging. Most of the gain here comes from removing manual recovery steps: a human restarting a service takes minutes and that alone can burn the entire four-nines monthly budget.
- 99.99% -> 99.999%: eliminate the facility (zone or region) itself as a single point of failure. Multi-region active-active or hot standby (a fully-running backup kept ready to take over instantly, unlike a cold standby that would first need to be started up and warmed), automated cross-region failover (not human-triggered), synchronous or tightly-bounded-lag replication for the data that must survive a region loss, and rigorous testing of the failover path itself (chaos drills: deliberately triggering the failover in a controlled test so a broken failover path is discovered on a Tuesday afternoon, not during a real outage), because at this tier the failover mechanism is now a bigger risk to availability than the failures it's protecting against.
- Beyond 99.999%, the limiting factor usually isn't infrastructure, it's deployment risk (bad releases) and dependency risk (a vendor or DNS provider you don't control), so the remaining budget goes to progressive rollouts, fast automated rollback, and reducing the number of hard external dependencies on the critical path.
Worked example: composing a dependency chain
A request that serially depends on a load balancer (99.99%), an app tier (99.95%), and a database (99.99%) has a combined availability equal to the product of the individual availabilities, because all three must be up simultaneously:
Aserial=0.9999×0.9995×0.9999=0.9993That's roughly 99.93%, worse than any single component, which is why a system built entirely from 99.99%-rated pieces chained together does not automatically deliver 99.99% end to end. Adding a redundant standby database (parallel, either one being up is sufficient) with independent 99.99% availability changes only that term:
Adb,pair=1−(1−0.9999)2=1−0.00012=0.99999999so the pair is effectively always up, and the chain's availability is then bounded by the weakest remaining serial link (the app tier at 99.95%), not the database.
Trade-offs & pitfalls
- Availability composes multiplicatively across a serial chain and the weakest link dominates: chasing five nines on your database while your app tier sits at three nines is wasted spend.
- Each nine costs disproportionately more: 99.9% to 99.99% is mostly process and automation (cheap-ish); 99.99% to 99.999% usually means paying for a second region and the operational overhead of keeping it truly independent (expensive, and dangerous if the failover path itself is untested).
- Downtime budgets don't distinguish planned from unplanned; a team that spends its whole error budget on deploy-related outages hasn't actually built a more resilient system, just a riskier release process.
- A very common interview trap: treating "99.99% uptime" as a promise about any single request rather than a time-integrated average. A system can meet 99.99% for the year while having a full 50-minute outage in one bad afternoon.
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.