Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

SD
System Design
0/13 completed
Beginner
What is system design?How the internet worksBack-of-the-envelope estimation
Intermediate
Scaling basicsLoad balancersCachingDatabases at scale
Advanced
Sharding and consistent hashingMessage queues and event streamingConsistency, CAP and distributed transactionsReliability and observability
Pro
Designing a URL shortenerDesigning a chat app
Tracks / System Design / Advanced

Reliability and observability

At scale, something is always failing: a disk, a server, a network link, a dependency, a deploy. Reliable systems don't avoid failure; they expect it, contain it, recover automatically, and make it visible. This lesson covers the defensive patterns (timeouts, retries, circuit breakers, rate limiting, bulkheads) and how to measure reliability with SLOs and observability.

Timeouts

A call without a timeout can wait forever, holding a thread, a connection and memory. Under load, slow dependencies exhaust these resources and take down services that were otherwise healthy. Every network call needs a timeout, shorter than the caller's own deadline.

Retries, done right

Retries fix transient failures, and can turn a small outage into a big one. If 10,000 clients retry immediately, a struggling service gets three times the traffic just when it can least handle it. Retry only idempotent operations (or ones with idempotency keys), cap the attempts, and spread them out with exponential backoff and jitter:

Python · editable

Jitter turns a synchronised retry storm into a gentle spread.

Circuit breakers

When a dependency is clearly down, stop calling it for a while: fail fast, use a fallback, and give it room to recover. A circuit breaker has three states:

 CLOSED ──(too many failures)──▶ OPEN ──(after a cool-down)──▶ HALF-OPEN
   ▲                                                             │
   └──────────────(a trial request succeeds)─────────────────────┘
                   (a trial request fails → back to OPEN)
Python · editable

At t=7 the cool-down has passed, so one trial request goes through (the half-open state); the service is still down, so the breaker opens again. At t=12 the next trial succeeds and the breaker closes. While open, users get a degraded but working page (generic recommendations) instead of a slow error, and the struggling service gets no traffic until a trial request succeeds.

Rate limiting and load shedding

Protect your services from clients, not just from dependencies. A sliding window limiter counts each client's requests over the last N seconds:

Python · editable

(The APIs track's rate-limiting lesson covers the token bucket.) In distributed systems the counters live in Redis so all servers share them. When the whole system is overloaded, load shedding rejects low-priority work first (analytics, recommendations) to keep critical paths (checkout, login) alive.

Bulkheads and graceful degradation

Like the watertight compartments of a ship, bulkheads isolate resources so one failure can't sink everything: separate connection pools or thread pools per dependency, separate clusters for critical customers. Combine with graceful degradation: decide in advance which features can be switched off (feature flags) and what the fallback is for each.

Redundancy and recovery

  • Replicate stateful components across availability zones; automate failover.
  • Back up and regularly test restores.
  • Make deployments reversible: blue-green or canary releases, automatic rollback on error spikes.
  • Chaos engineering: deliberately kill servers or inject latency in controlled experiments to prove the system copes.

Measuring reliability: SLIs, SLOs and error budgets

Term Meaning Example
SLI (indicator) A measurement of user experience % of requests under 300 ms; % of requests without 5xx
SLO (objective) The target for an SLI 99.9% of requests succeed, measured over 30 days
SLA (agreement) A contract with customers, with penalties Credits if availability drops below 99.5%
Error budget 100% minus the SLO: how much failure is acceptable 0.1% of requests may fail this month
Python · editable

Error budgets turn reliability into a shared, numeric decision between product and engineering teams.

Observability

You can't fix what you can't see. The three pillars:

  • Metrics: numbers over time (requests per second, error rate, latency percentiles, queue depth, CPU). Cheap to store, great for dashboards and alerts. Use percentiles (p50, p95, p99), not averages: the average hides the slowest users.
  • Logs: detailed records of events, structured as JSON, with request IDs.
  • Traces: the path of one request across services, with the time spent in each (OpenTelemetry, Jaeger, Tempo). Essential in microservices.

Start with the golden signals for every service: latency, traffic, errors, saturation. Alert on symptoms users feel (error rate, latency SLO burn), not on every CPU blip, and write a runbook for each alert.

Practice

  1. Change the circuit breaker's cooldown to 3 seconds and the threshold to 2. Trace what happens.
  2. Implement a "fixed window" rate limiter and show how a client can send 2× the limit across a window boundary.
  3. Define two SLIs and SLOs for a food-delivery app's "place order" flow.
✎ Check your understanding

1.Why add random jitter to retry delays?

2.What does an open circuit breaker do?

3.An SLO is 99.9% successful requests per month. What is the error budget?

← Consistency, CAP and distributed transactions