Skip to content

Latest commit

 

History

56 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System Design Illustrated

Learn system design by changing the numbers and watching what breaks.

45 plain-English modules, interactive labs, and runnable Python demos. Free, no sign-up, nothing to install.

Open the course →  ·  Traffic simulator  ·  Topic library  ·  Flashcards

CI License: MIT

The traffic simulator: sliders for incoming requests, servers, per-server capacity, failed servers and cache hit rate, with the resulting backend capacity and shortfall

Why this one

Most system design material tells you the answer. Here you can take a server offline, drop the cache hit rate, or double a traffic burst, and watch what happens to the numbers. Every module works through a real example with concrete figures, and the figures in the text come from a demo.py you can run yourself.

You don't need a computer-science degree. If a module uses a word before explaining it, that's a bug: please open an issue.

What's inside

🧭 Trail Notes course Six short lessons that follow one website as it grows, from a single request to surviving a regional outage, then a capstone. Progress saves in your browser.
🎛️ Interactive labs Traffic and cache simulator · DNS cache · Consistent hashing vs. modulo · Quorum reads · Queue backlog
📚 45 modules Each one goes analogy → picture → worked numbers → trade-offs → interview questions → self-check.
🐍 Runnable demos Every module has a zero-dependency demo.py. Run python demo.py in any module folder.
🗂️ Flashcards All 45 modules as review cards in the browser.
📐 References Back-of-the-envelope cheat sheet · Decision flowcharts · calculate.py capacity calculator
🧪 Practice Timed mock interviews and rubrics · Event-driven order processing lab · Multi-region recovery · Auth

Where to start

  • New to system design? Take the Trail Notes course, then read Part 0 and Part 1 below in order.
  • Interview coming up? Follow the study guide: it has a first-pass plan and timed mock interviews.
  • Reading Kleppmann or Alex Xu? The book-to-course reading map pairs each chapter with modules and exercises.

In each module, read 🧒 The 30-second version first. If it clicks, keep going; if not, re-read the analogy and look at the picture. Run the demo, then finish with ✅ Check yourself.

About the case studies. Each module has a REAL_WORLD_EXAMPLES.md describing how companies such as Google, Netflix and Stripe approach the pattern. Most of these aren't source-checked yet, so treat specific numbers as unverified. Help checking them is very welcome: see issue #9.

🚦 Status legend

Badge Meaning
✅ Deep — full beginner-friendly module (analogy, diagrams, worked numbers math, trade-offs, top 5 interview Q&A, quiz, runnable demo.py, and REAL_WORLD_EXAMPLES.md)
🟡 Under review — content exists but hasn't been fully fact-checked yet
⬜ Planned — on the syllabus, folder not created yet

🗺️ The big picture

Live Request Lifecycle Simulation

Almost every large web app is some combination of the boxes below. Each part of the syllabus zooms into one area of this picture.

flowchart LR
    U(["👤 User"]) --> DNS["🌐 DNS"]
    U --> CDN["⚡ CDN"]
    U --> LB["⚖️ Load balancer"]
    LB --> GW["🚪 API gateway<br/>(auth, rate limits)"]
    GW --> S1["⚙️ Service A"]
    GW --> S2["⚙️ Service B"]
    S1 <--> C["🚀 Cache"]
    S1 <--> DB[("💾 Database<br/>replicas + shards")]
    S2 --> Q["📬 Queue / log"]
    Q --> W["👷 Workers"]
    W --> DB
Loading

📚 Books & Resources this syllabus follows

All explanations here are written from scratch in plain language, synthesizing the industry's most acclaimed system design roadmaps and books:

Short name Source Resource
DDIA Designing Data-Intensive Applications — Martin Kleppmann (O'Reilly)
SDI-1 / SDI-2 System Design Interview: An Insider's Guide, Volumes 1 & 2 — Alex Xu (Vol. 2 with Sahn Lam)
UDS Understanding Distributed Systems — Roberto Vitillo
WSSE Web Scalability for Startup Engineers — Artur Ejsmont
Microservices Microservices Architecture Patterns & Service Mesh Design (Microservices.md)
REST API RESTful Architecture & API Semantics (RESTfulArchitecture.md)

📖 Master Syllabus

Part 0 · Foundations

# Concept Status What you'll learn Core Resource
26 Scaling from 1 to Millions of Users ✅ Single box to multi-tier: web, DB read-replicas, cache, CDN, stateless scaling SDI-1 ch 1 · WSSE ch 1
27 Back-of-the-Envelope Estimation ✅ Powers of two, Latency numbers every engineer should know, QPS and storage sizing SDI-1 ch 2 · Jeff Dean
28 Distributed Unique ID Generator ✅ Snowflake 64-bit time-sortable IDs, UUIDv4 vs Ticket Servers vs DB auto-increment SDI-1 ch 7

Part 1 · Networking & Traffic

# Concept Status What you'll learn Core Resource
01 Client–Server Networking ✅ TCP vs UDP, HTTP/1.1 → 2 → 3, WebSockets, gRPC UDS: reliable & secure links, APIs
02 Domain Name System (DNS) ✅ Recursive vs authoritative resolvers, Anycast routing, TTL, Geo-DNS UDS: discovery
03 Load Balancing ✅ L4 vs L7, round-robin, least connections, consistent hashing, health checks UDS: network load balancing · WSSE ch 3
04 API Gateways & Proxies ✅ Reverse proxies, TLS termination, header mutation, edge auth WSSE ch 4
05 Rate Limiting Fundamentals ✅ Token bucket, leaky bucket, fixed window, sliding window log & counter SDI-1 ch 4 · UDS: upstream resiliency
32 REST API Design & Idempotency ✅ HTTP verb semantics, Idempotency-Key headers, atomic deduplication, RFC 9110 RESTfulArchitecture.md · Stripe API

Part 2 · Storing Data

# Concept Status What you'll learn Core Resource
06 Relational vs Non-Relational DBs ✅ SQL vs Document, Key-Value, Columnar, Graph — when to use which DDIA ch 2 · WSSE ch 5
07 Database Replication ✅ Single-leader, multi-leader, leaderless; synchronous vs asynchronous, replication lag DDIA ch 5 · UDS: replication
08 Database Partitioning / Sharding ✅ Range vs Hash partitioning, secondary index partitioning, rebalancing shards DDIA ch 6 · UDS: partitioning
09 Storage Engines & Indexing ✅ B-Trees vs LSM-Trees, SSTables, Write-Ahead Logs (WAL), Bloom filters DDIA ch 3
29 Database Transactions & Isolation ✅ ACID, Dirty Reads, Non-Repeatable Reads, Phantom Reads, Lost Updates, Write Skew, Snapshot Isolation, SSI DDIA ch 7 · UDS: transactions
30 Data Encoding & Schema Evolution ✅ JSON vs Protobuf vs Avro, Forward & Backward compatibility, schema registries DDIA ch 4

Part 3 · Caching & Edge

# Concept Status What you'll learn Core Resource
10 Caching Patterns ✅ Cache-Aside, Write-Through, Write-Behind, Write-Around, Refresh-Ahead WSSE ch 6 · UDS: caching
11 Cache Eviction & Invalidation ✅ LRU, LFU, FIFO, TTLs, Cache Stampede (Thundering Herd) mitigation WSSE ch 6
12 Content Delivery Networks (CDNs) ✅ Edge PoPs, Origin shielding, Push vs Pull CDNs, Cache-Control headers UDS: HTTP caching · WSSE ch 3

Part 4 · Distributed-Systems Thinking

# Concept Status What you'll learn Core Resource
13 CAP & PACELC Theorems ✅ Consistency, Availability, Partition tolerance trade-offs in normal and partitioned states DDIA ch 9
14 Consistency Models ✅ Strict Linearizability, Sequential, Causal, Read-After-Write, Monotonic, Eventual DDIA ch 9 · UDS: replication
15 Consensus & Leader Election ✅ Raft state machine, leader heartbeat, log replication, split votes, quorum math DDIA ch 9 · UDS: leader election
16 Consistent Hashing ✅ Hash rings, virtual nodes (vnodes), minimal key movement during rebalancing SDI-1 ch 5
31 Time, Clocks & Ordering ✅ NTP clock drift, Last-Write-Wins data loss, Lamport Timestamps, Vector Clocks, Google TrueTime DDIA ch 8–9 · UDS: time

Part 5 · Async Processing & Microservices

# Concept Status What you'll learn Core Resource
17 Message Queues & Event Streaming ✅ Queues (RabbitMQ) vs Distributed Logs (Kafka), consumer groups, at-least-once DDIA ch 11 · SDI-2 ch 4
18 Event Sourcing & CQRS ✅ Immutable append-only event streams, temporal queries, read/write model separation DDIA ch 11–12
19 Distributed Transactions ✅ Two-Phase Commit (2PC) vs Saga pattern (Choreography vs Orchestration) DDIA ch 9 · UDS: transactions
20 Fault Tolerance & Resilience ✅ Timeouts, exponential backoff with full jitter, circuit breakers, bulkheads UDS: resiliency
33 Microservices & Service Mesh ✅ Service registry, sidecar proxy (Envoy), control plane (Istio), distributed tracing, mTLS Microservices.md · Martin Fowler

Part 6 · Full System Designs (Production Case Studies)

# Concept Status What you'll learn Core Resource
21 URL Shortener ✅ Base62 encoding, 100:1 read/write ratio, 301 vs 302 redirects, Bloom filter collision checks SDI-1 ch 8
22 Distributed In-Memory Cache ✅ Redis/Memcached architecture, slab allocation, consistent hashing, LRU eviction SDI-1 ch 6
23 Real-Time Chat Application ✅ WebSocket connection pools, presence servers, group chat fanout, message persistence SDI-1 ch 12
24 Video Streaming Platform ✅ Chunked upload, HLS / DASH adaptive bitrate, distributed transcoding worker DAGs SDI-1 ch 14
25 Distributed Rate Limiter ✅ Multi-datacenter sliding window counter, Redis Cluster Lua scripts, token sync SDI-1 ch 4
34 News Feed System ✅ Fanout-on-write vs Fanout-on-read, Celebrity outbox routing, Redis ZSET timelines SDI-1 ch 11
35 Global Notification System ✅ APNs, FCM, SMS, Email, priority queue tiers, deduplication windows, DLQ SDI-1 ch 10
36 Distributed Web Crawler ✅ Mercator URL frontier, per-host politeness, Bloom filter URL dedup, SimHash SDI-1 ch 9
37 Search Autocomplete (Typeahead) ✅ In-memory Trie, node-level Top-K caching, batch frequency aggregation, debouncing SDI-1 ch 13
38 Cloud File Storage & Sync ✅ 4MB block chunking, SHA-256 deduplication, Delta Sync, optimistic conflicted copies SDI-1 ch 15 (Google Drive)
39 Proximity Service & Nearby Places ✅ Geohash Base-32 encoding, 9-cell boundary resolution, Haversine distance, Uber H3 SDI-2 ch 1 (Yelp / Uber)
40 Digital Wallet & Payment System ✅ Double-entry bookkeeping (Debit=Credit), Idempotency keys, reconciliation, PSP timeouts SDI-2 ch 11 (Stripe / PayPal)
41 Hotel & Ticket Reservation System ✅ Double-booking prevention, 10-minute hold TTLs, optimistic locking, multi-day atomic ledger SDI-2 ch 7 (Airbnb / Booking)
42 Real-Time Gaming Leaderboard ✅ Redis Sorted Sets, Skip Lists, fractional tie-breaking, million-player ranking SDI-2 ch 10 (Google Play / Netflix Games)
43 Distributed Job & Task Scheduler ✅ Distributed cron coordination, Hashed Timing Wheels, worker heartbeats, failover recovery SDI-2 ch 6 (Google Chronos / Conductor)
44 Metrics Monitoring & Alerting System ✅ TSDB, Gorilla XOR compression, pull vs push scraping, downsampling, alert flapping prevention SDI-2 ch 5 (Google Monarch / Netflix Atlas)
45 Ad Click Aggregation & Analytics ✅ Tumbling/hopping windows, event-time watermarks, late event side outputs, bot click fraud filter SDI-2 ch 4 (Google Ads / Keystone)

Progress: 45 modules · 0 under review · 0 planned (100% Complete)


🏢 Real-world case studies

Each module includes a REAL_WORLD_EXAMPLES.md companion. Most aren't source-checked yet; see issue #9.

Module Core Topic Production Deep Dives & Architectures Link
01 Client–Server Networking Google QUIC deployment · Netflix Zuul 2 gateway Read Deep Dive
02 Domain Name System (DNS) Google Public DNS caching and anycast · Route 53 failover · Netflix capacity planning Read Deep Dive
03 Load Balancing Google Maglev · Netflix client-side balancing and overload protection Read Deep Dive
04 API Gateways & Proxies Netflix Zuul filter chain on Netty vs Envoy (built at Lyft) configured over xDS, as in Google Cloud Service Mesh (source-checked) Read Deep Dive
05 Rate Limiting Stripe rate limiters and load shedders (source-checked) vs Netflix Adaptive Concurrency Limits (Little's Law) Read Deep Dive
06 SQL vs NoSQL Databases Google Bigtable vs Spanner (from the papers) · Discord MongoDB → Cassandra → ScyllaDB (source-checked) Read Deep Dive
07 Database Replication Google Spanner Paxos replication vs Amazon Dynamo and Cassandra leaderless replication (source-checked) Read Deep Dive
08 Database Partitioning Google Bigtable range splits · Uber Schemaless fixed shards · Discord bucketed partition keys (source-checked) Read Deep Dive
09 Storage Engines & Indexes Bigtable memtables and SSTables · LevelDB levels · RocksDB compaction styles (source-checked) Read Deep Dive
10 Caching Patterns Facebook TAO leader/follower tiers · Netflix EVCache zone replicas · Bigtable scan and block caches (source-checked) Read Deep Dive
11 Cache Invalidation & Eviction Facebook memcache leases, mcsqueal and Gutter · Caffeine W-TinyLFU (source-checked) Read Deep Dive
12 Content Delivery Networks Netflix Open Connect appliances in ISPs · Cloudflare tiered cache and Argo · Google Global Cache (source-checked) Read Deep Dive
13 CAP & PACELC Theorems Google Spanner is technically CP, effectively CA (Brewer) · Dynamo/Cassandra PA/EL (Abadi) (source-checked) Read Deep Dive
14 Consistency Models Spanner external consistency · Cosmos DB five levels · DynamoDB per-read choice (source-checked) Read Deep Dive
15 Consensus & Leader Election Google Chubby (Paxos) · Raft · etcd under Kubernetes (source-checked) Read Deep Dive
16 Consistent Hashing Amazon Dynamo virtual nodes · Cassandra token ring · Discord fast ring lookups (source-checked) Read Deep Dive
17 Message Queues & Streaming Netflix Keystone Kafka (1.5T events/day) vs Google Cloud Pub/Sub Serverless Routing Read Deep Dive
18 Event Sourcing & CQRS Uber Trip Lifecycle Platform & CQRS vs Netflix Studio Production Asset Pipeline Read Deep Dive
19 Distributed Transactions Google Percolator Snapshot 2PC vs Uber / Netflix Temporal Saga Orchestrator Read Deep Dive
20 Fault Tolerance & Resilience Netflix Chaos Engineering (Chaos Monkey, ChAP) vs Google SRE Overload Shedding & Deadlines Read Deep Dive
21 System Design: URL Shortener Bitly 10B+ Clicks/Mo Base62 Platform vs Google / Twitter Malware Defense & 302 Redirects Read Deep Dive
22 System Design: In-Memory Cache Twitter / X Twemproxy & Pelikan Segregated Slabs vs Netflix EVCache Hybrid Tier Read Deep Dive
23 System Design: Real-Time Chat WhatsApp 100B Msgs/Day Erlang BEAM Engine vs Discord 100M+ WebSocket Elixir/Rust Read Deep Dive
24 System Design: Video Streaming Netflix Dynamic Optimizer & Chunked ABR vs YouTube Parallel Transcoding & VCUs Read Deep Dive
25 System Design: Rate Limiter Cloudflare eBPF / XDP Line-Rate Drops vs Stripe Atomic Redis Lua Sliding Windows Read Deep Dive
26 Scaling 1 to Millions of Users Google Search Infrastructure Evolution vs Netflix Monolith-to-AWS Cloud Migration Read Deep Dive
27 Back-of-the-Envelope Estimation Google SRE Cluster Capacity Sizing vs Netflix Global Streaming Bandwidth Modeling Read Deep Dive
28 Distributed Unique ID Generator Twitter / X Snowflake ID Architecture vs Discord & Instagram 64-Bit Time-Sortable Keys Read Deep Dive
29 DB Transactions & Isolation Google Spanner two-phase locking + TrueTime · PostgreSQL SSI · Stripe idempotency keys (source-checked) Read Deep Dive
30 Data Encoding & Schema Evolution Protocol Buffers field numbers vs Avro + Schema Registry (source-checked) Read Deep Dive
31 Time, Clocks & Ordering Lamport clocks · Google TrueTime · Amazon Dynamo vector clocks (source-checked) Read Deep Dive
32 REST API Design & Idempotency Stripe 24h Idempotency-Key Protocol vs Google Cloud API Design Guidelines & gRPC Transcoding Read Deep Dive
33 Microservices & Service Mesh Google Borg Stubby to Istio/Envoy Mesh vs Netflix Spring Cloud Eureka, Zuul & Hystrix Read Deep Dive
34 News Feed System Twitter / X Earlybird In-Memory Timelines vs Meta TAO Graph & Deep Learning Ranking Models Read Deep Dive
35 Global Notification System Netflix Hermes Multi-Channel Messaging Platform vs Google Firebase Cloud Messaging (FCM) Read Deep Dive
36 Distributed Web Crawler Google Googlebot Caffeine Planetary Crawling vs Internet Archive Heritrix WARC Storage Read Deep Dive
37 Search Autocomplete (Typeahead) Google Instant Keystroke Typeahead at Edge vs Netflix Fuzzy Levenshtein Actor/Title Search Read Deep Dive
38 Cloud File Storage & Sync Dropbox Magic Pocket 4MB Chunking Engine vs Google Drive Colossus & Spanner Metadata Read Deep Dive
39 Proximity Service & Nearby Places Uber H3 Hexagonal Hierarchical Spatial Index vs Google Maps S2 Geometry Library Read Deep Dive
40 Digital Wallet & Payment System Stripe Ledger and API idempotency · PayPal capture retries Read Deep Dive
41 Hotel & Ticket Reservation System Google Hotels & Travel Spanner Instant Booking vs Netflix Live Events & Studio Soundstage Booking (Conductor Saga) Read Deep Dive
42 Real-Time Gaming Leaderboard Google Play Games Bigtable Inverted Key Leaderboards vs Netflix Games Real-Time Social Challenges (Redis ZSET) Read Deep Dive
43 Distributed Job Scheduler Google Borg Chronos Distributed Paxos Cron vs Netflix Conductor / Meson Workflow Orchestration (Dynomite) Read Deep Dive
44 Metrics Monitoring & Alerting Google Monarch regional collection · Netflix Atlas dimensional time series Read Deep Dive
45 Ad Click Aggregation Google Ads Photon Active-Active Multi-Datacenter Streaming vs Netflix Keystone Real-Time Flink Pipeline (1.5T events/day) Read Deep Dive

➕ Adding a new concept

  1. Copy TEMPLATE.md into a new folder: the next free number plus a short name, e.g. 46-distributed-search-engine/README.md.
  2. Fill in every section. The non-negotiables: an analogy, at least one picture, one worked example with real numbers, and a quiz.
  3. Put any runnable code in the same folder as demo.py.
  4. Create a companion REAL_WORLD_EXAMPLES.md with primary sources for production claims. Include the date and measurement window for company metrics. Label your own sketches and workloads as illustrative.
  5. Update the row in the syllabus above: add the link, set the status, update the progress line.

🤝 Contributing

Corrections are the most useful contribution: a wrong number, an unclear sentence, or a case study claim without a source. Small PRs are welcome, and every contributor is credited.

  • 🔎 Source-check a case study: pick a module from issue #9.
  • 🐛 Found a mistake, typo, or inaccuracy? Open an issue using our Mistake Report Template or submit a PR. Catching mistakes makes the curriculum better for everyone.
  • 🏢 Share Your Production War Stories: Add your team's real-world architectural case study to any module's REAL_WORLD_EXAMPLES.md via our Case Study Template.
  • 💡 Propose New Topics or Labs: Have an idea for a modern system design topic (e.g. Vector DBs, CRDTs, edge computing)? Propose a new module.
  • 📖 Review Our Guidelines: Read CONTRIBUTING.md for step-by-step PR instructions and our Code of Conduct.

📝 License

MIT © Aniket Chavan. Book titles are referenced for further reading only. No text or figures are reproduced from them.

Releases

Packages

Contributors

Languages