An engineering-first, open-source curriculum designed to bridge the chasm between theoretical distributed systems architecture and real-world production engineering. Every concept is analyzed through first principles, failure mechanics, trade-off equations, industry battle-scars, and runnable Docker verification labs.
Interactive Curriculum β’ Quickstart (60s) β’ Learning Philosophy β’ Lab Directory β’ Contributing Guide
Jump directly to any phase in the curriculum:
| Phase | Focus Domain | Key Invariant / Trade-off | Documentation Guides | Companion Docker Lab |
|---|---|---|---|---|
| Phase 1 | π Foundations & Core Trade-offs | Little's Law, PACELC, Serializability | 5 Guides |
01-latency-vs-throughput |
| Phase 2 | π Networking & Traffic Ingress | Anycast, L4 vs L7, Consistent Hashing | 6 Guides |
02-consistent-hashing |
| Phase 3 | β‘ Communication Protocols | Binary Protobuf vs JSON, QUIC, SSE | 5 Guides |
03-grpc-vs-rest |
| Phase 4 | πΎ Data Layer & Persistence | LSM-Trees vs B-Trees, WAL, Sharding | 5 Guides |
04-replication-lag |
| Phase 5 | π Caching Strategies | Cache Stampede, XFetch, ARC Eviction | 4 Guides |
05-cache-stampede |
| Phase 6 | π¨ Async Messaging & Event Streams | Deduplication, DLQ, Outbox Pattern | 6 Guides |
06-idempotent-consumer |
| Phase 7 | π‘οΈ Distributed Reliability | Circuit Breakers, Bulkheads, Sagas | 5 Guides |
07-circuit-breaker |
| Phase 8 | π Observability & Monitoring | Trace Context, Error Budgets, SLOs | 4 Guides |
08-distributed-tracing |
Most system design resources isolate architecture to abstract boxes on a whiteboard. When systems scale to
This repository enforces an immutable 5-Stage Pedagogical Loop across every module:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE 5-STAGE LEARNING PIPELINE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
[ 1. CONCEPT ] ββββββββββΊ [ 2. CATASTROPHE ] ββββββββΊ [ 3. TRADE-OFF ] βββββββββΊ [ 4. INDUSTRY CASE ] ββ
β’ First principles β’ Real-world outages β’ Invariant analysis β’ Meta, Netflix, Uber β
β’ Mathematical formulas β’ Cascading saturation β’ PACELC / CAP bounds β’ Stripe, Amazon models β
β’ State boundaries β’ Thundering herds β’ Latency vs Memory β’ Real post-mortems β
β’ Topology diagrams β’ Split-brain partitions β’ Consistency vs Avail β’ Telemetry baselines β
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββΊ [ 5. RUNNABLE LAB ] ββββββββββΊ [ REINFORCED MASTERY ]
β’ Docker Compose sandbox β’ "I saw the system break under load,
β’ Fault injection harness quantified the inflection point,
β’ Synthetic load benchmarks and verified the mitigation in code."
β’ Grafana / Prometheus / Jaeger
Each lab runs a production-like distributed microcosm in Docker Compose, fully instrumented with telemetry:
βββββββββββββββββββ HTTP / gRPC βββββββββββββββββββββββββ
β Traffic Gen β ββββββββββββββββββββββββΊ β Ingress / Gateway β
β (k6 / wrk2) β β (Envoy / NGINX) β
βββββββββββββββββββ ββββββββββββ¬βββββββββββββ
β β
β Synthetic Fault Injection βΌ
β (Toxiproxy / Chaos Engine) βββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββΊ β Application Cluster β
β (Go / Node / Rust) β
ββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
βΌ βΌ
ββββββββββββββββββββββ ββββββββββββββββββββββ
β State / Storage β β Observability Pod β
β (Postgres / Redis) β β (OTel, Prometheus) β
ββββββββββββββββββββββ ββββββββββββββββββββββ
Experience a production failure mode and verify its mitigation in real time.
Ensure you have the following installed on your machine:
- Docker Engine
v24.0+& Docker Composev2.20+ - GNU Make
v4.0+ - curl and git
docker --version && docker compose version && make --versionClone the repository and spin up Lab 05: Cache Stampede:
# 1. Clone the repository
git clone https://github.com/your-username/system-design-roadmap.git
cd system-design-roadmap
# 2. Start the lab environment via Make
make run lab=05-cache-stampede
# (Alternative direct Docker Compose command):
# cd labs/05-cache-stampede && docker compose up -d --build# A. Execute the unmitigated cache stampede benchmark (simulating key expiry at 5,000 QPS)
make test-unmitigated lab=05-cache-stampede
# B. Check container logs and database connection pool exhaustion
make logs lab=05-cache-stampede
# C. Apply the distributed mutex / probabilistic early expiration (XFetch) fix
make test-mitigated lab=05-cache-stampede# Stop containers and remove lab network
make stop lab=05-cache-stampedeEvery topic links directly to an exhaustive documentation guide in docs/ and points to its corresponding hands-on lab in labs/.
docs/
βββ 01-foundations/ # Latency, throughput, availability, consistency models, CAP/PACELC
βββ 02-networking/ # Anycast, L4/L7, reverse proxies, load balancing, consistent hashing, CDNs
βββ 03-protocols/ # TCP/UDP, HTTP evolution, REST/GraphQL/gRPC, WebSockets/SSE, polling
βββ 04-data-layer/ # RDBMS vs NoSQL, indexes & B-Trees, replication, sharding, WAL
βββ 05-caching/ # Caching tiers, access patterns, eviction policies, stampede mitigation
βββ 06-messaging/ # Pub/sub, streaming logs, idempotency, DLQs, backpressure, outbox pattern
βββ 07-reliability/ # Rate limiting, circuit breakers, bulkheads, sagas, distributed locks, CQRS
βββ 08-observability/ # Metrics/logs/traces, health checks, distributed tracing, alerting & SLOs
The mathematical invariants and theoretical principles governing all distributed systems.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| Latency vs. Throughput | Littleβs Law ( |
Cascading queue starvation during sudden Black Friday traffic bursts | lab-01 |
| High Availability & SLAs | Availability math (99.9% vs 99.999%), Error budgets, MTTD / MTTR | Multi-region cloud storage outages cascading to downstream tiers | lab-01 |
| Consistency Models | Strict serializability, Linearizability, Sequential, Causal, Eventual | Stale balance reads in high-frequency fintech ledger accounts | lab-01 |
| CAP & PACELC Theorems | Trade-offs during network partitions, PACELC latency penalties | Split-brain partition during transient top-of-rack switch flapping | lab-01 |
| Back-of-the-Envelope Math | Power-of-two approximations, byte math, bandwidth & IOPS sizing | Capacity exhaustion leading to emergency scale-out failure | lab-01 |
π§ͺ Companion Lab:
labs/01-latency-vs-throughput/β Benchmark how worker pool starvation causes p99 latency explosions while throughput plateaus.
How packets travel from user devices across global networks to backend application workers.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| DNS Resolution & Anycast | BGP routing, recursive resolvers, TTL trade-offs, GeoDNS | BGP route hijacking and misconfigurations causing global outages | lab-02 |
| L4 vs. L7 Load Balancing | Packet inspection, TCP termination, TLS offload, kernel bypassing | Connection exhaustion on L7 reverse proxies under SYN floods | lab-02 |
| Reverse Proxy vs. API Gateway | Path routing, auth termination, TLS termination, egress mesh | API Gateway memory leaks during token validation thundering herds | lab-02 |
| Load Balancing Algorithms | Round Robin, Least Connections, IP Hash, Weighted Round Robin | Hash hotspots crashing unevenly distributed backend nodes | lab-02 |
| Consistent Hashing | Hash rings, virtual nodes, bounded loads, churn minimization | Mass cache invalidation ( |
lab-02 |
| CDN Architecture (Push vs. Pull) | Edge caching, origin shields, cache-control headers, stale-while-revalidate | Origin collapse caused by unshielded edge cache mass expirations | lab-02 |
π§ͺ Companion Lab:
labs/02-consistent-hashing/β Simulate cache key distribution and migration during node additions/removals with virtual nodes.
Serialization performance, transport mechanisms, and network efficiency across microservices.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| TCP vs. UDP & QUIC | Head-of-line blocking, 3-way handshake, congestion control (BBR) | Packet drop storms causing stream stalls in multiplexed HTTP/2 | lab-03 |
| HTTP Evolution | HTTP/1.1 pipelining, HTTP/2 multiplexing, HTTP/3 UDP transport | Head-of-line blocking at the transport layer under packet loss | lab-03 |
| REST vs. GraphQL vs. gRPC | Protobuf binary encoding, schema enforcement, N+1 query problem | Mobile network overhead from bloated JSON payload serialization | lab-03 |
| WebSockets vs. SSE | Full-duplex persistent connections vs. HTTP unidirectional streams | File descriptor exhaustion at 500k concurrent WebSocket clients | lab-03 |
| Polling Mechanisms | Short polling, long polling (hanging GET), comet architectures | Database connection pool collapse under aggressive client polling | lab-03 |
π§ͺ Companion Lab:
labs/03-grpc-vs-rest/β Benchmark throughput, CPU consumption, and wire payload sizes comparing Protobuf/gRPC against JSON/REST.
Storage engines, disk access patterns, replication topologies, and ACID guarantees.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| RDBMS vs. NoSQL | Relational integrity, document stores, wide-column, graph models | Deep joining across denormalized documents causing OOM crashes | lab-04 |
| Database Indexing & B-Trees | B+ Trees, LSM-Trees (SSTables/MemTables), write amplification | Random disk I/O thrashing due to missing compound indexes | lab-04 |
| Replication Strategies | Single-leader, multi-leader, quorum replication ( |
Asynchronous replication lag causing reading-own-writes anomalies | lab-04 |
| Sharding & Partitioning | Range vs. Hash sharding, cross-shard joins, re-sharding coordination | Celebrity hotkeys causing catastrophic single-shard disk saturation | lab-04 |
| Write-Ahead Logging (WAL) | Append-only logs, ARIES recovery algorithm, fsync durability | Database corruption following unexpected power loss during dirty flush | lab-04 |
π§ͺ Companion Lab:
labs/04-replication-lag/β Spin up a MySQL primary-replica cluster, inject heavy write loads, and measure asynchronous read inconsistencies.
Reducing database load, minimizing response times, and preventing cache-related outages.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| Caching Tiers | Client-side, Edge/CDN, Application local, Distributed in-memory | Inconsistent cache state across local node memories | lab-05 |
| Cache Access Patterns | Cache-Aside, Write-Through, Write-Behind, Refresh-Ahead | Dual-write race conditions corrupting database state | lab-05 |
| Eviction Policies | LRU, LFU, FIFO, 2Q, Adaptive Replacement Cache (ARC) | High-churn cold data evicting hot working sets | lab-05 |
| Stampede & Avalanche | Mutex locking, probabilistic early expiration (XFetch), jitter | Simultaneous key expiration triggering catastrophic DB meltdown | lab-05 |
π§ͺ Companion Lab:
labs/05-cache-stampede/β Recreate a 5,000 QPS cache stampede on Redis and benchmark distributed locking vs. probabilistic early expiration.
Decoupling services, managing backpressure, and ensuring reliable asynchronous delivery.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| Message Queues vs. Pub/Sub | Competing consumers, point-to-point queues, topic fan-out | Unacknowledged message backlogs driving broker nodes into OOM | lab-06 |
| Queues vs. Event Streams | Ephemeral queues (RabbitMQ) vs. Append-only logs (Kafka/Redpanda) | Head-of-line poison messages blocking consumer partition progress | lab-06 |
| Idempotency | Idempotency keys, deduplication windows, natural idempotency | Duplicate billing chargebacks caused by network retry storms | lab-06 |
| Dead Letter Queues (DLQ) | Poison pill detection, retry count limits, delayed exponential retry | Malformed payloads infinitely retrying and crashing consumers | lab-06 |
| Backpressure & Flow Control | Pull vs. push models, reactive streams, bounded channel buffers | Unbounded in-memory consumer queues crashing under traffic burst | lab-06 |
| Transactional Outbox | Two-phase commit avoidance, Change Data Capture (Debezium) | Dual-write inconsistency where DB committed but message failed | lab-06 |
π§ͺ Companion Lab:
labs/06-idempotent-consumer/β Implement a robust Redis-backed deduplication consumer and test duplicate message rejection under chaos.
Preventing localized errors from triggering system-wide cascading failure.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| Rate Limiting Algorithms | Token Bucket, Leaky Bucket, Fixed Window, Sliding Window Log | API abuse causing backend resource exhaustion during scraping spikes | lab-07 |
| Circuit Breakers & Retries | Closed/Open/Half-Open states, exponential backoff, full jitter | Retry storm DDOSing an already struggling downstream service | lab-07 |
| Bulkhead Pattern | Thread pool isolation, process isolation, resource quotas | Unresponsive third-party API consuming all gateway worker threads | lab-07 |
| Distributed Locks & Sagas | Redlock algorithm, fencing tokens, Saga choreography vs orchestrator | Zombie leader writing to database after split-brain timeout | lab-07 |
| CQRS & Event Sourcing | Command-Query Responsibility Segregation, replayable audit logs | Complex projection desynchronization in read models | lab-07 |
π§ͺ Companion Lab:
labs/07-circuit-breaker/β Inject high downstream latency with Toxiproxy and watch circuit breakers prevent cascading thread pool starvation.
Transforming runtime telemetry into actionable operational intelligence and alerting.
| Topic Guide | Core Invariants & Mathematical Formulations | Production Catastrophe Analyzed | Companion Lab |
|---|---|---|---|
| Metrics, Logs & Traces | Counter/Gauge/Histogram, cardinality costs, structured logging | High-cardinality label explosion crashing Prometheus nodes | lab-08 |
| Health Checks & Heartbeats | Liveness vs. Readiness probes, shallow vs. deep health checks | Deep health check hammering downstream DB during service recovery | lab-08 |
| Distributed Tracing | W3C TraceContext, span propagation, context injection, sampling | Blind spots during microservice latency degradation incidents | lab-08 |
| Alerting & SLOs | SLI/SLO/SLA definitions, multi-window burn rate alerts, error budgets | Alert fatigue causing engineers to miss critical customer outages | lab-08 |
π§ͺ Companion Lab:
labs/08-distributed-tracing/β Trace cross-service RPC calls across 4 microservices using OpenTelemetry, Envoy, and Jaeger.
All labs are isolated, containerized environments situated in labs/. Each lab contains a dedicated docker-compose.yml, load generators, and step-by-step verification commands.
labs/
βββ 01-latency-vs-throughput/ # Benchmark queue saturation, concurrency, and p99 cliffs
βββ 02-consistent-hashing/ # Visual node balance, ring redistributions, and hotspot simulation
βββ 03-grpc-vs-rest/ # Binary Protobuf vs JSON HTTP/1.1 throughput & serialization benchmarks
βββ 04-replication-lag/ # Master-replica replication lag monitoring under heavy write stress
βββ 05-cache-stampede/ # Thundering herd simulation & distributed mutex/probabilistic caching
βββ 06-idempotent-consumer/ # Deduplication strategies under aggressive at-least-once message redeliveries
βββ 07-circuit-breaker/ # Cascading failure prevention, thread pool isolation, and fallback logic
βββ 08-distributed-tracing/ # Multi-hop trace context propagation with OpenTelemetry and Jaeger
| Lab Command | Target Environment | Key Metrics Observed | Quick Link |
|---|---|---|---|
make run lab=01-latency-vs-throughput |
Go Worker Pool + Hey Benchmark | Requests/sec, p50/p95/p99 latency (ms), Queue Depth | View Lab |
make run lab=02-consistent-hashing |
Python Node Ring + MurmurHash | Key distribution variance, Rehash % upon node addition | View Lab |
make run lab=03-grpc-vs-rest |
Rust/Go Dual Service Cluster | Payload size (bytes), CPU time per request, Max QPS | View Lab |
make run lab=04-replication-lag |
MySQL Primary + 2 Asynchronous Replicas | Seconds_Behind_Master, replication stream delay |
View Lab |
make run lab=05-cache-stampede |
Node.js API + Redis + PostgreSQL | DB connection pool exhaustion, CPU spikes, cache hits/sec | View Lab |
make run lab=06-idempotent-consumer |
RabbitMQ / Kafka + Redis Deduplicator | Duplicate rate, idempotency key TTL accuracy, latency | View Lab |
make run lab=07-circuit-breaker |
Envoy + FastAPI + Toxiproxy Fault Injector | Trip threshold rate, error response time, recovery time | View Lab |
make run lab=08-distributed-tracing |
4 Polyglot Services + OTel + Jaeger | End-to-end trace depth, span durations, context headers | View Lab |
To guarantee consistency, rigor, and technical depth across the roadmap, every documentation topic must follow this exact 6-part anatomy:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE 6-PART TOPIC SPECIFICATION β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. CONCEPTUAL CORE & MENTAL MODEL β
β β’ First principles definition β
β β’ Visual ASCII topology diagram β
β β’ Invariants and mathematical formulation β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. THE CATASTROPHE (PRODUCTION FAILURE MODE) β
β β’ Concrete scenario at 100k+ QPS β
β β’ Step-by-step breakdown of how the failure propagates β
β β’ System telemetry during the crash β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. ENGINEERING TRADE-OFFS & CONSTRAINTS β
β β’ CAP / PACELC theorem positioning β
β β’ Space vs. Time & Latency vs. Consistency matrix β
β β’ When NOT to use this pattern β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4. BATTLE-TESTED INDUSTRY ARCHITECTURE β
β β’ Real-world implementation (e.g. Meta TAO, Netflix Zuul, Stripe) β
β β’ Architecture diagram of production solution β
β β’ Specific operational metrics and telemetry signals β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5. ANTI-PATTERNS & COMMON PITFALLS β
β β’ Common misconceptions in interviews and designs β
β β’ Subtle edge cases (clock drift, network splits, zombie leaders) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 6. HANDS-ON VERIFICATION LAB β
β β’ Direct pointer to companion Docker lab in labs/ β
β β’ Step-by-step terminal commands to reproduce and fix β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
A centralized Makefile automates lab lifecycles, load testing, and container management:
# Display help and available targets
make help
# List all available runnable labs
make list
# Launch a specific lab (builds and starts containers in detached mode)
make run lab=05-cache-stampede
# View real-time aggregated logs of a running lab
make logs lab=05-cache-stampede
# Restart a running lab
make restart lab=05-cache-stampede
# Stop a specific lab environment
make stop lab=05-cache-stampede
# Tear down all running lab containers and prune unused networks
make cleanWe welcome contributions from engineers, architects, and researchers worldwide. Whether refining a mathematical proof, documenting an industry post-mortem, or building a new runnable lab, your contributions make distributed systems engineering accessible to everyone.
- Fork & Branch:
git clone https://github.com/your-username/system-design-roadmap.git cd system-design-roadmap git checkout -b feature/topic-name - Follow the Standard Anatomy: Every new topic in
docs/must strictly implement the 6-Part Standard. - Use ASCII Architecture Topologies: Ensure all architecture flows use crisp ASCII code blocks for effortless rendering across all environments.
- Test Your Lab Locally:
make run lab=<your-lab> make logs lab=<your-lab> make stop lab=<your-lab>
- Open a Pull Request: Submit your PR with a clear summary, benchmark outputs, and references to real-world incidents or academic papers.
For full guidelines, PR templates, and community norms, see CONTRIBUTING.md.
This repository, including all documentation, architecture guides, and lab source code, is open-source software licensed under the MIT License.
Built with engineering discipline by the open-source community.
If this roadmap helps you design and scale more resilient distributed systems, consider starring βοΈ the repository.