skip to content

learn.smmeyer.devsystem-design07

system-design/07

production · core · ~3h practice

Reliability & resilience

outcome

Translate availability goals into redundancy, recovery, isolation, and graceful degradation.

Plan a practice session · ~3h including exercises
Read + trace the worked example
25 min
Assignment + constraint variations
100 min
Timed drill + repeated explanations
35 min
Closed-book recall + self-review
20 min

This is a suggested practice budget, including drawing, variations, and repeated drills. Reading is the first block. Split the work across sessions and use the rubric to judge when to move on.

why this matters

Reliability is a budget and a design property, not a last-minute replica. Strong candidates connect user-visible SLOs to dependency math and concrete failure modes.

coverage

  • Targets: SLIs, SLOs, 99.9/99.99/99.999, error budgets.
  • Redundancy: multi-AZ, multi-region, correlated failure.
  • Failover: active-passive, active-active, detection and recovery.
  • Patterns: timeouts, backoff, jitter, circuit breakers, bulkheads.
  • Recovery: RPO, RTO, backups, restore tests.
  • Degradation: load shedding, dependency isolation, feature tiers.

mental model

Prevent, detect, contain, recover—each layer answers a different failure question.

  1. 1 →Prevent

    Capacity + redundancy

  2. 2 →Detect

    SLIs + alerts

  3. 3 →Contain

    Bulkheads + shed

  4. 4 →Recover

    Failover + restore

Read in numbered order: prevent → detect → contain → recover.

lessons

01An SLO is a product promise

99.9% allows about 43.8 minutes of downtime per 30-day month; 99.99% about 4.38 minutes. Multiplying serial dependency availability reveals why every synchronous hop spends budget.

Define the service-level indicator before choosing a target. For checkout, count valid purchase attempts that finish correctly within a deadline, not successful health checks on the API process. State exclusions and measurement location. A 99.9% success target permits one bad attempt per thousand over its window; a time-based availability target over a 30-day month permits 43.2 minutes. These are different denominators.

An error budget turns the target into a change policy. When the service has consumed most of its budget, slow risky releases and prioritize the dominant failure source. Do not spend days eliminating harmless internal errors while customers cannot complete checkout. Slice the indicator by region or critical customer class so an aggregate success rate cannot hide a concentrated outage.

For sequential required dependencies, success requires all stages. Under an illustrative independence assumption, three 99.9% available stages yield 0.999³ ≈ 99.70% availability. Real failures may be correlated, so multiplying advertised numbers is not a guarantee. Use the calculation to find dependency risk, then examine shared networks, stores, credentials, and deployment paths.

  • Measure the user journey, not server uptime
  • Error budgets govern release vs reliability work
  • Tail latency can violate an SLO before total outage

02Redundancy must cross failure domains

Two replicas on one host do not protect against host loss; two AZs may not meet a three-AZ quorum strategy. Active-active improves recovery but adds state and conflict complexity.

Two application instances on one host survive a process crash but not host loss. Two zones can still depend on one regional control plane or database. Name the failure domain each copy crosses, and trace whether the surviving path has credentials, configuration, data, and capacity. Redundancy only helps if the replacement is both independent enough and able to serve.

RPO is the maximum accepted data-loss interval; RTO is the target recovery duration. If asynchronous replication can lag 30 seconds, an immediate failover may lose recent accepted writes even when recovery takes only a minute. Decide whether to wait, recover from another log, or explicitly reconcile missing operations. A faster failover does not by itself improve RPO.

A restore test is part of the design. Restore a representative backup, apply subsequent logs, validate business invariants, and measure time until useful traffic can resume. Include DNS or routing changes, caches, and dependent clients. A runbook that ends at “database starts” has not established that checkout works.

  • Failover detection can be riskier than failover mechanics
  • Exercise backups by restoring them
  • Know RPO (data) and RTO (time)

03Stop failure from spreading

Bound every call with a timeout and concurrency limit. Circuit breakers stop futile work. Bulkheads reserve resources. Jitter avoids synchronized retry waves. Graceful degradation preserves the critical product path.

A slow dependency consumes callers' connections and worker slots. If those callers keep accepting new requests, a local problem spreads. Bound concurrency per dependency, set deadlines, and shed work before shared resources are exhausted. A bulkhead reserves separate capacity so an optional recommendation call cannot consume every checkout worker.

A circuit breaker stops repeated calls to a failing dependency for a period and probes for recovery. It complements timeouts and budgets; it does not decide what response is safe. An unavailable recommendation can be omitted, while an unavailable payment authorization cannot be replaced by invented success. Define degraded behavior by workflow and test it with the dependency actually unavailable.

Retries and fallbacks need capacity too. If every request fails over to a smaller pool, the fallback becomes the next outage. Reserve headroom, reduce admitted traffic, or lower the service level deliberately. During recovery, ramp traffic rather than releasing an entire backlog at once. Reliability includes returning to steady state without a second failure wave.

  • Caller deadline should shrink downstream
  • Shed cheap and early
  • Prefer static/history over total failure when safe

worked example

Spend an availability budget deliberately

A checkout path targets 99.9% successful requests over a 30-day window. Assume failures are evenly spread for the time-equivalent calculation.

  1. The allowed failure fraction is 0.001. Thirty days contain 43,200 minutes, giving a time equivalent of 43.2 minutes; request-based accounting still counts actual failed requests.
  2. A 20-minute outage would consume about 46% of that time-equivalent budget. At peak traffic it can consume a larger share of a request-based budget.
  3. Shed optional recommendations before rejecting checkout. Put independent dependency pools behind bounded queues and deadlines.
  4. Test recovery with the primary payment dependency slow rather than fully down; a reachable but slow dependency can exhaust concurrency.

Design decision: Protect the critical user operation with isolation and an explicit degradation ladder.

Limit: Dependency availability percentages cannot generally be multiplied without assumptions about independence and the request path.

Teaching scenario · traffic, prices, and capacity values are illustrative.

assignment

Produce: A checkout SLO, failure matrix, and recovery runbook.

Paper, a text editor, or a spreadsheet is enough. Model access and paid services are optional.

  1. Define the success numerator, denominator, measurement window, and excluded traffic.
  2. Rank features by what can degrade; trace timeout, retry, and concurrency limits for each dependency.
  3. Run a tabletop incident with a slow payment dependency, recover it, and revise the runbook from the gaps.

Change a constraint

  • The outage occurs during the largest sale of the month.
  • The fallback is also slow because it shares the same database.

Self-review rubric

  • The SLO measures user success.
  • Optional failures cannot consume all checkout capacity.
  • Recovery includes queue draining and a safe return from fallback.

If a criterion is missing, revise that part of the artifact before rating your practice below.

Compare a sample artifact after your attempt

One defensible answer under these assumptions. Compare the reasoning and checks with your work; other designs can satisfy the same contract.

Checkout targets 99.9% valid requests completing correctly within the declared deadline over 30 days. The time-equivalent below assumes uniform request traffic.

SLI = good eligible checkout attempts / eligible checkout attempts
Budget: 0.1% bad; uniform 30-day equivalent = 43.2 minutes
DB loss → stop unsafe writes; fail over only with valid data authority
Recommendation loss → omit optional recommendations
Payment timeout → unresolved operation; reconcile before replay
Runbook: detect symptom → halt rollout → bound load → recover owner
         → verify accepted writes + checkout trace → ramp traffic

Declare exclusions and measure at the user workflow. A failing optional dependency should not consume all checkout workers. RTO covers time to usable recovery; RPO covers accepted data loss. Practice restoring and reconciling data, not only starting replacement processes. Shared databases can defeat a supposedly independent fallback.

Check your artifact

  • A region or database loss has an assigned recovery owner and invariant check.
  • Peak-sale traffic changes the request impact of an outage even if its duration is unchanged.
  • The fallback has headroom and does not depend on the same failed resource without a deliberate limitation.

A tempting mistake: Turning a request-based SLO into minutes without stating a traffic assumption can conceal much worse customer impact during peak periods.

cumulative practice

Relay · build and evolve a private file service

Project brief

Keep one design document for Relay, a tenant-aware file service. Start with 100k daily users, ten downloads per user/day, 10k uploads/day, 1 MB typical bodies, 30-day retention, and a 5× download peak. Files are private to workspaces. Treat these as fictional planning assumptions. Later chapters add previews, recovery, regional constraints, compute, and an assistant. Record each change rather than replacing the earlier version; the final review combines the whole packet. These activities share the chapter's existing practice budget.

Keep one project document across this track. Reconstruct earlier reasoning before opening notes, then revise the same artifact. Use part of the assignment and review budget for this work. If you enter mid-course, sketch the earlier decisions first using the linked chapters.

Add to your project: Relay's download SLO, preview degradation rule, and recovery matrix.

Set a 99.9% successful-download target and recover its uniform 30-day time equivalent from memory. Decide whether preview failure should fail downloads, and show how retry storms could consume the budget despite redundant workers.

Compare cumulative reasoning after your attempt

The uniform-time equivalent is 43.2 minutes; the actual SLI counts eligible downloads. Raw authorized downloads can remain available when optional previews fail. Separate preview capacity from download-serving resources, bound retries, and shed optional work. Recover preview ownership with fencing and idempotency instead of allowing every replacement to replay effects. Validate download success after recovery before ramping traffic.

Keep your first attempt and revision together. If your answer differs, identify the assumption or mechanism that explains the difference before rating your recall.

senior signal

Quantify the error budget and show the degradation ladder: full answer → smaller model → cached answer → queued job → explicit failure.

failure patterns

  • Setting 99.999% without cost justification
  • Adding retries without deadline/concurrency limits
  • Calling backups reliable without restore tests
  • Failing the whole request because an optional dependency is slow

knowledge checks

Start with these quick checks, then explain the closed-book questions in your own words.

  1. 01A 99.99% monthly SLO allows roughly…

    select an option to check your answer

  2. 02RPO answers…

    select an option to check your answer

closed-book recall

Close the worked example and explain these from memory. Answers are self-reviewed. Drafts stay on this page; save anything you want to keep in chapter notes.

Rate the assignment and recall together

Use the assignment rubric as evidence. Completion is your own judgment; this score schedules practice.

interview drill

Make an AI chat service survive loss of its primary model provider and one availability zone.

  • 99.95% chat submit
  • streaming
  • provider outage
  • AZ loss
compare a strong approach after your attempt

Keep edge and orchestration multi-AZ, isolate provider pools, and enforce per-provider circuit breakers. Route to a tested fallback model with disclosed capability change; preserve conversation writes before inference. If no provider is healthy, queue only when UX supports it. Track SLOs separately for submit, TTFT, and completion.

Compare decisions and failure behavior, then repeat with a changed constraint. Keep your own wording.

Use the timed mock workspace →

references

Sources offer deeper context. Provider capabilities and API contracts can change; check current official docs before implementing.

notes

saved locally