System Design, Visualized
Chapter 1 · Foundations
How a system is put together, and how to size it.
- 1.1 How a request flows: Follow reads, writes and images through every hop, break each hop on purpose, and learn the 30-second opening for any design answer.
- 1.2 Back-of-the-envelope math: Feel the latency ladder from nanoseconds to an ocean crossing, and turn daily users into QPS and storage in seconds.
- 1.3 Scaling: up or out: Push traffic until one big machine hits its ceiling, then scale out and fix the three things that break.
Chapter 2 · Core trade-offs
The vocabulary every design decision is argued in.
- 2.1 Availability and the nines: Compute what each nine allows, chain services together, and simulate a year of failures to see when redundancy works and when it does not.
- 2.2 CAP theorem: Cut the link between three replicas and watch a CP system return errors while an AP system serves stale data and loses writes on heal.
- 2.3 Consistency models: Route reads across a lagging leader and followers, watch users miss their own edits or go back in time, then fix it one guarantee at a time.
- 2.4 Load balancing: Run five balancing algorithms against the same traffic, slow one server down, kill another, and see who keeps tail latency and errors low.
Chapter 3 · Data
Where data lives and how it grows past one machine.
- 3.1 SQL vs NoSQL: Model one shop as tables and as documents, run five real queries step by step, then shard it and count the nodes each query touches.
- 3.2 Indexes: Search, range-scan and split a real B+tree, find the break-even point between an index and a full scan, and see which queries a composite index can serve.
- 3.3 Replication: Crash a leader under async, semi-sync and sync replication and count the acknowledged writes that vanish, then tune a leaderless quorum.
- 3.4 Sharding: Split 100,000 orders four ways, find the hot shard, add a shard and count what moves, and see how fan-out multiplies slow requests.
- 3.5 Consistent hashing: Watch keys move when a server joins, see why virtual nodes fix lopsided load, and walk the ring to place replicas.
- 3.6 Key-value store: Tune R and W while nodes fail and watch stale reads appear even with R + W > N, merge a cart with vector clocks, gossip a death across 256 nodes, and find 3 bad keys among 1,024 with a Merkle tree.
- 3.7 Unique ID generator: Build and decode a Snowflake ID bit by bit, push 8,000 requests into one millisecond, step the clock back and watch a naive generator issue 9,000 duplicates, then spend a 63-bit budget.
Chapter 4 · Scale and speed
Absorb traffic: caches, limits and asynchronous work.
- 4.1 Caching and CDNs: Race five eviction policies on the same 20,000 reads, replay the stale-cache race, defuse a stampede on a hot key, and tune a CDN cache key.
- 4.2 Rate limiter: Token bucket, sliding windows, the window-edge attack, and the Redis race that lets a 6th request through.
- 4.3 Message queues: Run a live broker: shrink the visibility timeout, crash consumers before the ack, inject a poison message, and watch duplicates, dead letters and backlogs appear.
- 4.4 Kafka partitions: Keys, ordering, idle consumers, hot partitions, and what really happens to offsets when a consumer crashes.
Chapter 5 · Reliability
Keep working when parts of the system fail.
- 5.1 Timeouts, retries and idempotency: Place a timeout on a real latency tail, watch retries keep a server down after the incident ends, then make a retried payment charge only once.
- 5.2 Circuit breakers: Break a dependency for 20 seconds and watch a shared thread pool drain, then add a circuit breaker and a bulkhead and replay the same minute.
- 5.3 Observability: See a mean that matches no request, average three p99s into a wrong answer, run four incidents through SLO burn-rate alerts, and find the slow span in a trace.
Chapter 6 · Full systems
Case studies that combine the building blocks.
- 6.1 URL shortener: Size a shortener from three sliders, generate codes four ways and see the collision math, then cache a Zipf-skewed read path and choose 301 or 302.
- 6.2 Chat app: Size a messenger, see why polling wastes 98% of requests, lose messages on a flaky network until sequence numbers and client ids fix the screen, and tune presence on a train ride.
- 6.3 News feed: Move the push/pull threshold across a heavy-tailed follower graph and watch writes trade for reads, then hydrate a page in 3 ms instead of 81 and see why offsets duplicate posts.
- 6.4 Payments ledger: Drive a $120 payment through authorize, capture, refund and payout with every entry summing to zero, then run 10,000 payments through timeouts and crashes until no one is charged twice.
- 6.5 Notification system: Send 10,000 notifications through a provider outage and an SMS cap until none are lost or doubled, then tame one user's noisy day from 70 buzzes to 5 without missing the 3 AM security alert.
- 6.6 Web crawler: Crawl a synthetic web with 50 fetchers and watch plain BFS send 189 requests a second to one site, fix it with per-site queues, defuse a calendar trap, and catch near-duplicate pages with SimHash.
- 6.7 Search autocomplete: Type into a live trie and watch a cached top-5 cut a lookup from 127 nodes to 3, shard prefixes by real traffic, and see a weekly rebuild miss a trending eclipse entirely.
- 6.8 Video streaming: Watch fixed 1080p freeze in a train tunnel while adaptive players keep going, find the cheapest number of videos to keep on the CDN, and cut a 300-minute encode to 3 by chunking.
- 6.9 File sync: Edit a real 2 MB file in memory and watch a 10-byte insertion force fixed blocks to re-send everything while content-defined chunks send 21 KB, then reconnect two offline devices without losing an edit.
Chapter 7 · Low-level design
A separate track: objects, patterns and UML.
- 7.1 Object-oriented design: Add electric cars to a switch-based parking lot and watch 3 files change, then add them to a polymorphic one and change nothing; flip through SOLID before/afters in Java and watch 32 notifier classes shrink to 8.
- 7.2 Design patterns: Swap parking prices at runtime, try to break a vending machine built from State classes, undo and redo through a Command stack, and match six problems to the pattern that fits, all in Java.
- 7.3 UML diagrams: Click an arrow to see the Java behind it (or the Java to see the arrow), step through a parking-lot exit with an alt box for a declined card, and drive an order through a state diagram that rejects invalid events.