📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š Interview question

How do you design a system for fault tolerance? Explain redundancy, availability zones and regions (for example Australia East and Australia Southeast), timeouts, retries and circuit breakers, and graceful degradation — and how you decide how much resilience a system actually needs.

Designing for fault tolerance: eliminating single points of failure, zone and region redundancy in Australia East/Southeast, timeouts, retries with backoff, circuit breakers, bulkheads, graceful degradation, RTO/RPO and choosing the right level of resilience.

Mid-Level Theory Intermediate availability-zones disaster-recovery fault-tolerance polly resilience system-design

🎯 Key points

  • Find single points of failure on the diagram: every box, every dependency
  • Zone redundancy (Australia East availability zones) protects against a datacentre failure
  • Region failover (Australia East to Southeast) protects against a regional outage; costs more and needs RTO/RPO
  • Timeouts on every remote call; retries with exponential backoff and jitter only for idempotent operations
  • Circuit breakers and bulkheads stop one failing dependency taking everything down
  • Graceful degradation: serve cached or partial results, turn off non-critical features
  • Resilience level follows the availability target and the cost of downtime
  • Test it: chaos experiments (Azure Chaos Studio), failover drills, game days

⏱ 30-second answer

Fault tolerance means the system keeps working, perhaps degraded, when parts fail. I design it in layers:

  • Redundancy: no single points of failure β€” multiple instances, zone-redundant services in Australia East, and regional failover to Australia Southeast if the RTO/RPO justify it.
  • Containment: timeouts on every call, retries with backoff and jitter for idempotent operations, circuit breakers and bulkheads so one slow dependency can't exhaust everything.
  • Degradation: fall back to cached data or turn off non-critical features.

Then I prove it with chaos tests and failover drills. The trade-off is cost and complexity versus downtime: zone redundancy is cheap, multi-region active-active is expensive, so the availability target decides.

πŸ—£ Full answer (senior)

How I would answer this in an interview

"I start with the diagram and ask of every box: what happens if this is slow, down, or returning errors? Anything whose failure takes the whole system down is a single point of failure, and I either remove it or accept it consciously. Then I match the resilience to the requirement β€” a 99.9% internal tool and a 99.99% payments service get very different designs.

The first layer is redundancy. Multiple app instances spread across availability zones in Australia East, and zone-redundant options for the data tier, like zone-redundant Azure SQL and Redis. That covers a datacentre failure at modest cost. Regional failover to Australia Southeast covers a whole-region outage, but it means geo-replication, a failover process and usually a non-zero RPO, so I only do it when the business can state an RTO and RPO that require it. For example, at [company] we [chose active-passive across regions for system X because of requirement Y].

The second layer is containing failure inside the code: a timeout on every outbound call, retries with exponential backoff and jitter only for idempotent operations, a circuit breaker so we stop hammering a dependency that's down, and bulkheads so one slow dependency can't use every thread or connection. In .NET that's AddStandardResilienceHandler from Microsoft.Extensions.Http.Resilience on top of Polly. The third layer is graceful degradation β€” show cached prices, hide recommendations, queue the order and confirm later. The mistake I see is retries without timeouts or jitter, which turn a brief blip into a retry storm. Resilience you haven't tested is a hope, not a design."


Failure scope and protection

Failure Protection Cost
Process crash, bad instance Multiple instances, health checks Low
Datacentre (zone) outage Zone-redundant services across availability zones Low to moderate
Region outage Geo-replication and failover to the paired region High
Dependency slow or down Timeouts, circuit breaker, fallback Low (code)
Bad deployment Slots/revisions, canary, fast rollback Low
Data corruption, deletion Point-in-time restore, soft delete, immutable backups Moderate

Containment patterns

Pattern Purpose .NET
Timeout Bound waiting HttpClient + resilience pipeline, CancellationToken
Retry with jitter Ride out transient faults Polly retry strategy
Circuit breaker Fail fast when dependency is down Polly circuit breaker
Bulkhead Isolate resources Concurrency limiter, separate pools
Fallback Degrade gracefully Cached value, default response

Active-passive across regions

            Azure Front Door (health probes)
             /                         \
   Australia East (active)      Australia Southeast (passive)
   App x N across zones         App (scaled down / warm)
   Azure SQL (zone redundant)--> geo-replica (failover group)
   Redis (zone redundant)        Redis (empty, warms on failover)
Target Monthly downtime budget Typical design
99.9% ~43 min Single region, multiple instances
99.95% ~22 min Zone redundant in one region
99.99% ~4 min Zone redundant plus automated regional failover

Production example

A pricing dependency started taking 30 seconds to respond. Without timeouts, the checkout API's requests piled up until thread pool starvation took the whole service down for 25 minutes. After adding a 2-second timeout, a circuit breaker and a fallback to the last known price (with a flag to re-price before payment), a repeat of the same dependency failure caused no checkout errors.

πŸ” What the interviewer is checking

Checks whether the candidate can find single points of failure, apply the right redundancy level, contain failures in code and justify the cost.

Green flags

  • Distinguishes zone and region failures and links them to RTO/RPO
  • Timeouts first, retries with jitter only for idempotent calls
  • Mentions circuit breakers, bulkheads and graceful degradation
  • Talks about testing resilience (chaos, drills)

Red flags

  • "Multi-region active-active" for everything
  • Retries without timeouts or backoff
  • No mention of what users see during failure

πŸ“š Learn in depth

1. Failures are normal

At scale, something is always failing: an instance, a disk, a network link, a dependency. Fault tolerance accepts that and designs so that individual failures don't become user-visible outages. The two numbers that matter are how often users are affected and for how long (availability and MTTR).

2. Redundancy and correlation

Redundancy only helps if failures are independent. Two instances on the same host, or in the same zone, fail together. Availability zones are physically separate datacentres within a region with independent power, cooling and networking. Regions are hundreds of kilometres apart. Australia East and Australia Southeast are an Azure region pair, which affects platform update sequencing and some geo-replication defaults.

3. RTO and RPO

  • RTO (recovery time objective): how long you can be down.
  • RPO (recovery point objective): how much data you can lose.

Asynchronous geo-replication means a non-zero RPO: writes committed in the primary region but not yet replicated are lost on forced failover. Zero RPO across regions needs synchronous replication, which adds latency to every write.

4. Why timeouts come first

Without a timeout, a slow dependency holds a request, a thread or async continuation, a connection and memory for as long as it likes. Under load these pile up until the caller fails too β€” a cascading failure.

slow dependency -> requests wait -> pool exhausted -> caller fails
      -> its callers wait -> ... -> whole system down

5. Retries, done safely

Retries help with transient faults but multiply load. Rules: retry only idempotent operations (or use idempotency keys), use exponential backoff with jitter so clients don't retry in sync, cap attempts, and have one layer own retries rather than every layer.

6. Circuit breakers

A circuit breaker counts failures; past a threshold it opens and fails fast for a break period, then lets a trial request through (half-open). This protects the dependency while it recovers and frees the caller from waiting.

7. Testing resilience

Azure Chaos Studio can inject faults such as VM shutdowns, network latency and zone-down scenarios. Failover drills prove that the runbook and DNS/Front Door routing work and measure the real RTO.

Try it yourself

  1. Draw your system's diagram and mark every single point of failure.
  2. Add AddStandardResilienceHandler to an HttpClient, point it at a WireMock.Net stub that delays 10 s, and observe the timeout and circuit breaker.
  3. Calculate the RPO of an asynchronous geo-replica with an average replication lag of 5 s.
  4. Run a Chaos Studio experiment that adds latency to a dependency and watch Application Insights.
  5. Do a planned failover of an Azure SQL failover group in a test environment and time it.

πŸ’» Code

Timeouts, retries with jitter and a circuit breaker for an outbound call, plus a fallback for graceful degradation.

// Program.cs β€” .NET 10, Microsoft.Extensions.Http.Resilience
using Microsoft.Extensions.Http.Resilience;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHttpClient<PricingClient>(c => c.BaseAddress = new Uri("https://pricing.internal"))
    .AddStandardResilienceHandler(o =>
    {
        // Total budget for the call including retries.
        o.TotalRequestTimeout.Timeout = TimeSpan.FromSeconds(3);
        // Each attempt must give up quickly.
        o.AttemptTimeout.Timeout = TimeSpan.FromSeconds(1);
        o.Retry.MaxRetryAttempts = 2;               // backoff with jitter by default
        o.CircuitBreaker.FailureRatio = 0.5;        // open at 50% failures...
        o.CircuitBreaker.MinimumThroughput = 20;    // ...once there is enough traffic
        o.CircuitBreaker.BreakDuration = TimeSpan.FromSeconds(15);
    });

builder.Services.AddMemoryCache();
var app = builder.Build();

app.MapGet("/prices/{sku}", async (string sku, PricingClient pricing, CancellationToken ct) =>
    Results.Ok(await pricing.GetPriceAsync(sku, ct)));

app.Run();

public sealed record Price(string Sku, decimal Amount, bool IsStale);

public sealed class PricingClient(HttpClient http, Microsoft.Extensions.Caching.Memory.IMemoryCache cache, ILogger<PricingClient> logger)
{
    public async Task<Price> GetPriceAsync(string sku, CancellationToken ct)
    {
        try
        {
            var price = await http.GetFromJsonAsync<Price>($"/prices/{sku}", ct)
                        ?? throw new InvalidOperationException("Empty price response");
            cache.Set(sku, price, TimeSpan.FromHours(1));
            return price;
        }
        catch (Exception ex) when (ex is HttpRequestException or TimeoutException
                                   or Polly.CircuitBreaker.BrokenCircuitException
                                   or Polly.Timeout.TimeoutRejectedException)
        {
            // Graceful degradation: last known price, flagged so checkout re-prices before payment.
            logger.LogWarning(ex, "Pricing unavailable for {Sku}; using cached price", sku);
            return cache.TryGetValue(sku, out Price? cached) && cached is not null
                ? cached with { IsStale = true }
                : throw;
        }
    }
}

⚠ Common mistakes

  • Mistake: No timeout on outbound calls. Why it is wrong: A slow dependency ties up requests and connections until the caller fails too. Instead: Set an attempt timeout and a total timeout on every remote call.
  • Mistake: Timeouts set far too aggressively. Why it is wrong: A timeout below the dependency's normal p99 turns ordinary slow requests into failures, which trips the circuit breaker on a healthy service and causes extra retries. Instead: Base timeouts on measured latency (for example a little above the dependency's p99) and review them when the dependency's behaviour changes.
  • Mistake: Retrying everything immediately. Why it is wrong: Synchronised retries multiply load on a struggling dependency and can turn a blip into an outage. Instead: Exponential backoff with jitter, capped attempts, idempotent operations only.
  • Mistake: Retrying at every layer. Why it is wrong: Three layers with three retries each make 27 attempts per user request. Instead: Let one layer own retries and pass the deadline down with cancellation.
  • Mistake: Redundancy that fails together. Why it is wrong: Instances in one zone or sharing one dependency go down together. Instead: Spread across availability zones and check shared dependencies.
  • Mistake: Multi-region active-active by default. Why it is wrong: It is expensive and brings data conflicts and replication complexity. Instead: Start with zone redundancy; add regional failover, or active-active, when RTO/RPO and the business case require it.
  • Mistake: Health checks that test every dependency for liveness. Why it is wrong: A database blip makes every instance restart at once. Instead: Liveness checks the process; readiness checks critical dependencies.
  • Mistake: Never testing failover. Why it is wrong: Runbooks, DNS and permissions rot, so the first real failover fails. Instead: Schedule failover drills and chaos experiments.

πŸ› Senior insight: trade-offs

Seniors size resilience to the cost of downtime, per service rather than per system. A checkout or payments path may justify regional failover, while the reporting service in the same product is fine with a single zone and a four-hour RTO. Each nine roughly multiplies cost and complexity, so they ask what an hour of outage costs and what the business will pay to avoid it. Zone redundancy is usually an easy yes; multi-region is a business decision with a price tag and a data-loss trade-off (RPO).

They also know where resilience can live. In-process libraries (Polly via Microsoft.Extensions.Http.Resilience) give fine control per call; on Kubernetes, a service mesh such as Istio or Linkerd can apply timeouts, retries and mTLS uniformly at the sidecar, but then retries must be owned by one layer, not both. And they look past infrastructure: most outages come from changes, so safe deployments (slots, canaries, feature flags, fast rollback) often add more availability than another region.

Option When it fits Cost When not to
Multiple instances, one zone Internal tools, 99.9% Lowest Customer-facing critical paths
Zone redundant (Australia East) Most production systems, 99.95% Small premium Region outage must be survived
Active-passive regions RTO minutes–hours, 99.99% Standby cost, drills No business case for regional loss
Active-active regions Near-zero RTO, global users Highest; conflict handling Strongly consistent single-writer data
Where resilience lives When it fits Cost When not to
In-process (Polly) Per-call policies, fallbacks with business logic Code in every service Many languages, need uniform policy
Service mesh Many services on Kubernetes, uniform mTLS and timeouts Sidecar latency and operations Small estate, App Service hosting

πŸ”— Follow-ups the interviewer may ask

  1. When: Candidate mentions retries after timeouts Why: Checks whether they understand that a timeout doesn't mean the work wasn't done
    How to answer

    You can't know. The request may have been lost, processed with the reply lost, or still be running. So the caller must treat a timeout as an unknown outcome: retry only operations that are idempotent, make others safe to retry by sending an idempotency key the server de-duplicates on, or check the outcome (status query, reconciliation) before acting again. Keep retries bounded and behind a circuit breaker, with a fallback for the user, so a slow dependency doesn't turn into a retry storm.

  2. When: Candidate mentions health checks or load balancer probes Why: Checks how health checks can cause cascading restarts
    How to answer

    A health check is an automated decision: the orchestrator or load balancer acts on it, so it must answer exactly the question the actor asks. Liveness asks "is this process stuck?", so the answer is a restart. It never checks shared dependencies. Readiness asks "should this instance get traffic now?" It checks warm-up and local essentials, not something every instance shares. Startup probes give slow starts time before liveness applies.

    The classic failure is a database check in liveness or readiness: one database blip makes every instance fail together. You get a fleet restart or zero healthy backends, which turns a partial outage into a total one. In ASP.NET Core I use tagged checks mapped to separate endpoints, keep them cheap and time-boxed, and keep detailed output internal. Dependency health goes to monitoring and alerts, where a human decides.

  3. When: Candidate proposes Australia East and Southeast for resilience Why: Checks practical Azure hosting and disaster-recovery design
    How to answer

    I build it in layers:

    • Compute: App Service Premium v3 (or a Container Apps workload-profile environment) in Australia East with zone redundancy, at least two instances, and a health check path.
    • Releases: a staging slot with warm-up and swap (or revisions with traffic splitting).
    • Network: traffic enters through Front Door Premium or Application Gateway with WAF, the app only accepts traffic from it; outbound uses VNet integration, and SQL, Key Vault and Storage are reached through private endpoints with public access off.
    • Identity and ops: managed identity everywhere, Application Insights and alerts on SLOs.
    • Resilience: a warm or cold standby in Australia Southeast with SQL failover groups and geo-redundant storage, all from IaC.

    The trade-off is cost and complexity (private DNS, more resources) versus a much smaller attack surface and a tested recovery path.

πŸ›  Real-world problems: how you handle them

Slow pricing dependency took checkout down
Situation
[Company]'s checkout API on [App Service / AKS] called an internal pricing service on every basket update; about [n] requests/s at peak.
Signals
p95 latency climbing from [x] ms to [y] s; thread pool queue length rising in dotnet-counters; Application Insights showing pricing dependency calls of [30] s; 5xx errors and health check failures across all instances.
Investigation
Application Insights application map showed the pricing dependency as the slow edge; dotnet-counters showed thread pool starvation; the code review found `HttpClient` calls with the default 100-second timeout and no circuit breaker.
Resolution
Immediate: restarted instances and asked the pricing team to roll back their change. Real fix: added the standard resilience handler with a 1-second attempt timeout, circuit breaker and fallback to the last known price, with a re-price step before payment.
Prevention
Resilience handler required on all `HttpClient` registrations (code review checklist and an analyser rule); chaos experiment in Azure Chaos Studio adding latency to the pricing service before each release; alert on circuit breaker open events.

How to tell it (STAR)

**S:** At [company], a slow release of the pricing service made every call take about [30] seconds, and our checkout API went down for [n] minutes. **T:** I led the fix so a dependency failure couldn't take checkout down again. **A:** I confirmed thread pool starvation with dotnet-counters and found our HttpClient had no timeout or circuit breaker. I added a resilience pipeline with a 1-second attempt timeout, a circuit breaker and a fallback to the last known price, flagged for re-pricing before payment, and added a Chaos Studio latency test to the release pipeline. **R:** When pricing failed again [weeks] later, checkout errors stayed at [near zero] and p95 stayed under [x] ms.

↩ Usually asked after

More in Core System Design

Last updated 23 Nov 2026.

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me