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.
What does a disaster recovery runbook actually need to contain to be useful during a real region failure? Walk through the essential sections: owner, RTO/RPO, step-by-step actions, and verification.
Sample Answer
Direct answer
A disaster recovery runbook is only useful if a stressed engineer can execute it top to bottom without needing to look anything else up. That means naming an owner, stating the RTO and RPO it is designed to meet, listing ordered and specific actions (exact commands or console steps, not descriptions), and ending with concrete verification steps that prove the system is actually back, not just that the steps were followed.
Structured elaboration
| Section | What it contains | Why it's required |
|---|---|---|
| Title and scope | Which system or service, and which failure modes it covers | A runbook that does not say what it's for gets grabbed for the wrong incident |
| Owner and escalation contacts | Primary owner, backup owner, and how to reach them, not just a name | Someone must be accountable for keeping it accurate and reachable during the incident |
| RTO / RPO | The target time to recover and the acceptable data loss this runbook is designed to hit | Without a target, "did the runbook work" has no answer |
| Prerequisites | Required access, credentials, tickets, and any upstream dependency that must already be healthy | Discovering you're locked out mid-incident is the worst time to find out |
| Step-by-step actions | Numbered, specific commands or console actions, including a rollback for each risky step | Vague steps like "promote the standby" force the responder to improvise under pressure |
| Verification steps | Health checks, smoke tests, and the specific metrics that confirm recovery | "The steps finished" is not the same as "the system works" |
| Post-incident tasks | Root cause capture, stakeholder communication, runbook update | A runbook that isn't updated after every real use rots |
Versioning and access. Store the runbook in source control with required review on changes, so every edit has an author and a diff. Test it in a real drill, not a tabletop discussion only, on a cadence tied to how critical the service is, quarterly for anything customer-facing. Keep it reachable when the primary systems it recovers are down: a runbook that lives only on an internal wiki hosted in the region that just failed is not a disaster recovery runbook.
Worked example
For a service with RTO = 30 minutes, a well-built runbook's step timings should sum to that budget, and the sum should be checked, not assumed:
| Step | Budget |
|---|---|
| Detection and paging | 5 minutes |
| Triage and decision to fail over | 5 minutes |
| Execution (promote standby, update routing) | 15 minutes |
| Verification (smoke tests, dashboards green) | 5 minutes |
That sum matching the stated RTO exactly is what makes the RTO a testable claim rather than a number pasted at the top of the document. If a quarterly drill shows execution consistently takes 20 minutes instead of 15, the runbook's RTO is wrong and needs to be corrected, not explained away.
Trade-offs & pitfalls
- A runbook with no owner drifts out of date the first time the architecture changes; ownership is not optional metadata.
- Testing via tabletop discussion only, never an actual drill, hides the gap between the steps sounding right and the steps working; most drift is caught only by execution.
- Over-specifying every command for a fast-moving system creates a maintenance burden that causes the runbook to be abandoned; balance specificity against how often the underlying commands change.
- Storing the only copy behind the same authentication system that depends on the region that just failed is a common, self-defeating mistake.
What's the difference between graceful degradation and fail-fast behavior? Give a concrete example of when you'd want each.
Sample Answer
Direct answer
Graceful degradation keeps serving a reduced version of the response (cached data, a simplified feature set, a fallback value) when a dependency is unhealthy, trading completeness for availability. Fail-fast does the opposite: it detects the problem quickly and returns an explicit error rather than attempting a degraded response, trading availability for correctness and speed of failure signaling.
When to use each
| Graceful degradation | Fail-fast | |
|---|---|---|
| Goal | Keep the user-visible experience mostly working | Avoid doing something wrong or wasting resources |
| Good fit | Read-heavy, non-critical, or cache-friendly paths | Writes with correctness or financial consequences |
| User sees | A slightly reduced experience, often unnoticed | A clear error, immediately |
| Risk if used wrong | Serving stale or wrong data silently | Unnecessary outages for things that could have degraded fine |
| Example | Product page shows a cached price and hides personalized recommendations when the recommendation service is down | Payment endpoint rejects the request immediately when the payment gateway is unreachable, rather than guessing |
Worked example
A product detail page calls three things to render: the core product data (must succeed), a recommendations service (nice to have), and a payment-availability check (must be correct). If the recommendations service is slow or down, the page graceful-degrades by omitting that section entirely and rendering everything else; a user who never look for recommendations doesn't notice a thing, and the page stays fast because it isn't waiting on a dependency it doesn't strictly need.
If the payment gateway is unreachable when a user tries to check out, fail-fast is the right call: returning a clear "payment temporarily unavailable, please retry" immediately is far safer than attempting to guess an outcome, queue the charge silently, or degrade to some partial payment state, any of which risks a duplicate charge, a lost order, or a customer charged for something that was never fulfilled.
Trade-offs & pitfalls
The decision comes down to whether the operation is idempotent (repeating it has the same effect as doing it once, so a retry can't cause harm) and non-critical (favor graceful degradation) or has real correctness or financial stakes (favor fail-fast). The common mistake is applying one pattern uniformly across a whole service: a system that fails fast on everything, including truly optional dependencies, takes unnecessary outages; a system that gracefully degrades everything, including payment or inventory writes, risks silent data corruption that's much harder to detect and clean up after than an outage would have been.
What does idempotency mean in the context of retries, and why does it matter? Walk through how you'd make a payment-creation endpoint safe to retry, including how you'd handle the idempotency key.
Sample Answer
Direct answer
Idempotency means performing the same operation multiple times has the exact same effect as performing it once. It matters for retries because network failures make it impossible for a client to reliably tell "the request failed" apart from "the request succeeded but the response was lost"; without idempotency, a client that retries after a timeout risks creating a duplicate side effect, like charging a customer twice for one order.
Making a payment-creation endpoint safe to retry
The standard mechanism is a client-generated idempotency key attached to the request:
- The client generates a unique key (a UUID) once per logical operation, before the first attempt, and sends it on every retry of that same logical operation in a header such as
Idempotency-Key. - The server does an atomic check-and-set against a persistent store keyed by that idempotency key: if the key is new, it proceeds with the charge; if the key already exists, it returns the previously stored result instead of processing the charge again.
- The check-and-set has to be atomic (a single transactional operation, not a read followed by a separate write) so two near-simultaneous retries can't both see "key doesn't exist" and both proceed.
- The stored result includes enough to reconstruct the original response (status, charge ID, amount) and a status field (
in_progress,succeeded,failed) so a retry that arrives while the first attempt is still executing gets told to wait or gets the eventual result, rather than racing ahead. - Keys are kept with a bounded TTL (commonly 24 to 72 hours) since indefinite retention is unnecessary once a client has almost certainly given up retrying, and TTL bounds the storage cost of the idempotency table.
sequenceDiagram
participant Client
participant API as API Region A
participant Store as Idempotency Store
participant PG as Payment Gateway
Client->>API: POST charges Idempotency-Key K1
API->>Store: check-and-set K1 in_progress
Store-->>API: new key proceed
API->>PG: create charge
PG-->>API: charge succeeded
API->>Store: save result for K1
API-->>Client: 200 OK response lost in transit
Client->>API: retry POST charges Idempotency-Key K1
API->>Store: check K1
Store-->>API: found status succeeded
API-->>Client: 200 OK cached result no new charge
Worked example
In the sequence above, the server actually completes the charge and writes the success result to the idempotency store, but the client's connection drops before the 200 response arrives, so from the client's point of view the request timed out. The client retries with the same key K1. The server's check-and-set finds K1 already marked succeeded, so it returns the stored response (the original charge ID and amount) directly and never calls the payment gateway again. Exactly one charge exists, regardless of how many times the client retries.
Harder extension: retries across a cross-region failover
The same duplicate-request risk gets worse if the retry lands on a different region than the original attempt. Say the first request goes to Region A, and before the response comes back, DNS or Anycast reroutes the client (as part of a regional failover) so the retry with the same idempotency key goes to Region B. If the idempotency store is region-local and not replicated, Region B has never heard of K1, sees it as a new key, and processes a second charge, exactly the failure the mechanism was supposed to prevent.
The fix is that the idempotency store itself has to be as available and as replicated as the failover design assumes the rest of the system is: either a globally consistent store (accepting the added write latency) or, more commonly for payments specifically, delegating idempotency to the payment gateway itself, which usually supports its own idempotency keys and is already a single global system of record regardless of which region initiated the call. Relying on the gateway's own dedupe as the backstop means even a fully region-local idempotency store failing open during a failover doesn't result in a real double charge.
Trade-offs & pitfalls
Idempotency keys add a write to the hot path (the check-and-set) and a storage system that has to be highly available, since if the idempotency store itself is down, you're forced to choose between blocking the write entirely or risking a duplicate. TTL choice is a real trade-off: too short and a legitimately slow client retry after the TTL expires creates a duplicate; too long and the storage grows unnecessarily and stale in-progress records from crashed requests linger. The most common mistake is only deduplicating the write itself while forgetting downstream side effects (an email receipt, a webhook fired to a third party) that happen inside the same logical operation and need to be gated by the same check, not fired unconditionally every time the handler runs.
A downstream service you depend on starts responding slowly, and requests to it start backing up on your side, growing queues and increasing latency. Walk through your immediate mitigations and your longer-term architectural fix, and explain the trade-off each one introduces.
Sample Answer
Direct answer: The immediate priority is to stop the slowdown from consuming your own resources: set aggressive timeouts, open a circuit breaker so you stop calling the failing dependency, and isolate the connection/thread pool used for that call so it can't starve everything else. The longer-term fix is architectural: decouple the caller from the dependency's latency entirely, usually via an async queue or by making the call non-blocking, so a slow downstream degrades throughput instead of taking the whole service down with it.
Structured elaboration
Why this happens (the mechanism): by Little's Law, the number of requests in flight L equals arrival rate λ times the time each request spends in the system W: L=λW. If a downstream call's latency goes from 50ms to 500ms while your request rate stays at, say, 200 requests/second, the in-flight count grows from L=200×0.05=10 to L=200×0.5=100, a 10x increase, purely from the latency change with no change in incoming traffic. If your thread or connection pool was sized for ~10-20 concurrent in-flight requests to that dependency, it's now exhausted, and requests start queueing on your side, which is exactly the symptom described.
Immediate mitigations (minutes, not a redesign):
| Mitigation | What it does | Trade-off it introduces |
|---|---|---|
| Tight timeouts | Caps how long you'll wait, preventing unbounded queue growth | Cuts off requests that might have succeeded a moment later; needs to be shorter than your own SLA to the caller |
| Circuit breaker | Stops calling the dependency once error/latency crosses a threshold, failing fast instead of queueing | Can trip on transient blips if thresholds are too sensitive; denies service even to calls that might succeed |
| Bulkhead (isolated pool) | Gives this dependency its own thread/connection pool so its slowdown can't exhaust pools shared by healthy dependencies | Reduces pooled efficiency (can't borrow capacity across dependencies); requires knowing sizing up front |
| Load shedding / fast 503 | Rejects excess requests immediately when queue depth crosses a threshold, protecting the instances still healthy | Directly reduces availability for shed requests; needs to shed selectively, not randomly, if some requests matter more |
Longer-term architectural fix:
- Decouple via an async queue: put a durable queue between the caller and the slow dependency so the caller can return quickly (accept-and-acknowledge) and the dependency is drained at its own sustainable pace, rather than the caller blocking on it synchronously. Trade-off: the caller can no longer return a synchronous success/failure for that operation; the interaction model has to change to something the client and product can tolerate (a "pending" state, a webhook, a poll).
- Idempotent retries with backoff and jitter: if retries are needed, they must be capped, exponential, and jittered so a fleet of callers doesn't retry in lockstep and re-create the exact overload it's recovering from. Trade-off: added complexity, and retries must be provably idempotent on the downstream side or they risk duplicate side effects.
- Capacity planning against the tail, not the average: provision the dependency (or the pool sized to call it) based on observed p99 latency, not p50, since it's the tail that determines when queues start building. Trade-off: costs more standing capacity for headroom that's idle most of the time.
Applying this to concrete variants of the same pattern: the reasoning above is the same whether the slow dependency is a payment-validation service (immediate: circuit breaker + fast-fail with a clear "try again" to the user rather than a silent hang; long-term: async payment confirmation via webhook), a message-queue consumer falling behind (immediate: shed or dead-letter the oldest low-priority messages, bulkhead the consumer pool by message type; long-term: scale consumers horizontally and partition by priority), a retry storm from a flood of client-side 503s (immediate: the client-side backoff-with-jitter above is the direct fix; long-term: make the shedding threshold adaptive so it doesn't itself become the trigger for a thundering herd), or a synchronous order-processing pipeline backing up (immediate: bulkhead the slow stage's pool; long-term: convert that stage to the async-queue pattern above).
Trade-offs & pitfalls
- Every immediate mitigation above trades some availability or correctness for stability: timeouts drop requests that might have succeeded, circuit breakers deny service during their open window, load shedding sacrifices some requests to save the rest. The point isn't to avoid the trade-off, it's to make it deliberately and visibly rather than let an unbounded queue make it for you via an eventual crash.
- A common wrong turn: adding retries as the first response to a slowdown. Naive retries without backoff amplify load on an already-struggling dependency and can turn a partial slowdown into a full outage (a retry storm).
- Circuit breakers and bulkheads need to be tuned against real traffic and latency distributions; thresholds copied from a different service's runbook are a common source of either false trips (unnecessary unavailability) or no protection at all (thresholds too loose to matter).
What's the difference between N+1 and N+2 redundancy? For a service normally sized at 10 instances, walk through what each strategy actually buys you in failure tolerance, and when the extra cost of N+2 is worth it.
Sample Answer
Direct answer: N+1 means you provision one spare unit beyond what's needed to serve current load, so the system tolerates exactly one simultaneous failure with zero capacity loss. N+2 provisions two spares, tolerating two simultaneous failures (or one failure plus a second one arriving while the first is still being repaired). For a service sized at 10 instances, N+1 is 11 instances and N+2 is 12; the extra instance in N+2 is worth it when failures are likely to be correlated or when repair (MTTR) is slow enough that a second failure landing during the first one's recovery window is a real possibility, not a hypothetical.
Structured elaboration
- What "N" means: N is the number of units actually required to serve load at your target performance, not the number you happen to run. If 10 instances are needed to handle peak traffic at acceptable latency, N=10.
- N+1: one extra unit. Any single instance, host, rack, or power supply can fail and the system still serves at full capacity from the remaining N. It does not protect against a second, overlapping failure.
- N+2: two extra units. Protects against two simultaneous failures, which matters specifically during the repair window of the first failure (you're running on N+1 capacity while node 1 is being replaced; if node 2 fails during that window, N+1 would drop you below N, but N+2 still covers you).
- When N+2's extra cost is worth it: the decision comes down to how correlated failures are and how long repair takes, not just how critical the service is in the abstract.
Worked example: quantifying the risk N+2 removes
A capacity shortfall only happens when multiple instances are down at the same time, which means the model has to use the instantaneous probability that an instance is down at any given moment, not the probability that it fails at some point during the year (an annual failure probability answers a different question and silently ignores repair-window overlap). The right building block is the instantaneous-unavailability formula: at any random moment, the fraction of time a single instance has historically spent broken and being repaired is MTTR divided by the full working-plus-repair cycle, MTBF+MTTR, which is exactly the probability that instance happens to be down at an arbitrary moment in time:
q=MTBF+MTTRMTTRPin illustrative values: each instance has an MTBF of 8,760 hours (fails on average about once a year) and an MTTR of 4 hours (time to detect and replace or restart a failed instance). Then:
q=8760+44=87644≈0.000456(0.0456%)That's the probability any single instance is down (mid-repair) at a random moment.
For N+1 (11 total instances), capacity drops below the needed N=10 only if 2 or more instances are down simultaneously:
P(down≥2∣n=11,q)=1−(011)(1−q)11−(111)q(1−q)10 =1−0.994991−0.004998=0.0000114(0.00114%)For N+2 (12 total instances), capacity drops below 10 only if 3 or more are down simultaneously:
P(down≥3∣n=12,q)=1−k=0∑2(k12)qk(1−q)12−k =1−0.994537−0.005450−0.0000137=0.0000000209(0.0000021%)Both numbers are tiny snapshot probabilities; the more useful reading is as the expected fraction of the year the system spends in a shortfall state, converted into expected annual downtime minutes by taking that same fraction-of-time-in-shortfall and multiplying it by the number of minutes in a year, 525,600 (365 days x 24 hours x 60 minutes), the standard way a fraction-of-time becomes an annual downtime figure:
N+1: 0.0000114×525,600≈6.0 minutes/year N+2: 0.0000000209×525,600≈0.011 minutes/year(≈0.66 seconds/year)So under this repair-window-conditioned model, N+1 carries about 6 minutes/year of expected capacity-shortfall exposure, and N+2 cuts that to about 0.01 minutes/year, roughly a 548x reduction, not because any instance's individual failure rate changed, but because a shortfall now requires a second failure to land inside the narrow repair window of the first, and adding a spare pushes that bar from "2 simultaneous" to "3 simultaneous," a much rarer event once q is small. Whether that ~6-minute-a-year difference is worth one extra instance's cost is exactly the trade-off to walk through out loud: for a service where even a few minutes of capacity shortfall risks an SLA breach, cutting expected exposure by roughly two and a half orders of magnitude for one extra instance is usually cheap insurance; for an internal batch service, shortfall risk this small to begin with is very likely not worth the extra spend.
Common concrete instances of the same reasoning: UPS/power-supply sizing (N+1 power modules in a rack survive one PSU failure; N+2 covers one failed unit plus one more failing during the swap), and network device sizing (N+1 top-of-rack switches vs N+2 when switch firmware upgrades take units offline for extended maintenance windows, effectively acting like a "planned failure" that N+1 alone can't absorb if an unplanned one happens at the same time).
Trade-offs & pitfalls
- N+2 isn't "more reliable" in a vacuum, it's specifically insurance against overlapping failures; if your MTTR is minutes and failures are rare and independent, N+1 is usually sufficient and N+2 is paying for a scenario that almost never occurs.
- Fault-domain correlation matters more than the raw redundancy count: N+1 spread across a single rack doesn't protect against a rack-level power failure taking out several "independent" instances at once; redundancy has to be placed in genuinely independent failure domains (different racks, AZs, or power feeds) or the N+1/N+2 math above doesn't hold, because the independence assumption breaks.
- A common wrong turn: treating N+1 as "one extra instance total" when instances are correlated (e.g., all on the same physical host or the same AZ). The formula only protects capacity if the spare's failure mode is independent of the others.
- N+2 costs roughly 20% more standing capacity than N+1's 10% here; that recurring cost has to be justified against the downtime cost it avoids, not assumed.
Unlock Full Question Bank
Get access to all 42 Fault Tolerance, High Availability, and Disaster Recovery interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.