HLD_LAB

HLD Lab

System design, one set at a time: the building blocks first (storage, scaling, caching, queues), then a timeboxed method, then the famous questions as staged model answers — attempt each stage before you open it. Your journal and re-design schedule live in this page and persist in this browser.

TRACK: SETS H0 → H12 DSA LAB → LLD LAB →

§◇ · YOUR DESK

Today

understood
designed
re-designs due
journal answered
cards to clear

Due for re-design

§00 · THE FULL MAP — SYSTEM DESIGN

The HLD atlas — every set, one table

System design rounds grade whether you can drive: name the trade-offs before being asked, quantify with estimation, and go deep on the one hard sub-problem the interviewer signals. Sets H0–H5 are the building blocks; H6 turns them into a repeatable method; H7+ are the famous questions, each an application of blocks you already own.

SetTopicThe skill it buildsAnchor questionsDone
H0Vocabulary & the numberslatency table, availability nines, QPS/storage arithmeticestimation drills
H1The web tierDNS, L4/L7 load balancers, CDN, stateless services, autoscaling"what happens when you type a URL", senior edition
H2Storage enginesB-tree vs LSM, indexes, ACID, SQL vs NoSQL families — when whichschema-choice drills
H3Scaling datareplication, quorums, sharding, consistent hashing, CAP → PACELC"your database is hot — now what"
H4Cachinglayers, cache-aside vs write-through/back, invalidation, thundering herddesign a distributed cache
H5Async & queuesqueues vs pub/sub, the Kafka mental model, delivery semantics, outbox, backpressuredesign a notification system
H6The script + first designsthe 45-minute timeboxed method, end to endURL shortener · Pastebin · distributed rate limiter
H7Read-heavy classicsfanout on write vs read, precompute vs on-demandnews feed · autocomplete · YouTube · web crawler
H8Real-time classicswebsockets, presence, delivery receipts, orderingWhatsApp · live comments
H9Geo & matchinggeohash / quadtree indexes, supply–demand matchingUber · food delivery
H10Money & correctnessidempotency keys, ledgers, sagas, inventory under contentionpayment system · wallet · flash sale
H11Infra as the questionbuild the building blocks themselvesKV store (Dynamo-style) · message queue · blob store · metrics
H12Advanced gluedistributed locks, leader election, consensus at concept level, clocks, bloom/HLLdeep-dive ammunition

§★ · THE SYSTEM-DESIGN HOUR

The HLD interview script — timeboxed

  1. Requirements (5 min). Three to five functional requirements — then the non-functional ones that DECIDE the design: scale (how many users? reads vs writes?), latency, and the consistency-vs-availability preference. Name what’s out of scope, out loud.
  2. Estimation (3 min) — only where it changes a decision. DAU → QPS (÷ ~10⁵ per day, × 2–3 for peak), storage per year, bandwidth. One or two numbers, not a spreadsheet.
  3. API sketch (3 min). Three to five endpoints, request/response shapes only.
  4. Data model (5 min). The main tables/collections, the access patterns they serve, the sharding key candidate.
  5. High-level diagram (10 min). Client → LB → services → cache → store → queue. Then walk one request end-to-end through it — the walk catches what the boxes hide.
  6. Deep dives (10–15 min). The one or two genuinely hard sub-problems, chosen from the interviewer’s signals: fanout, hot keys, ordering, idempotency. This is where senior is decided.
  7. Wrap (5 min). Bottlenecks, single points of failure, monitoring, how the design evolves at 10×.
The senior differentiator

You VOLUNTEER trade-offs with reasons — “choosing availability over consistency here, because a stale like-count is harmless” — instead of being dragged to them. Every claim gets a because; every choice names the alternative it beat.

§★ · MEMORIZE THE EXPONENTS, NOT THE DIGITS

Latency numbers & estimation arithmetic

Every estimation in every design leans on a dozen physical facts. These are rounded on purpose — orders of magnitude are what decide designs:

OperationCostThe design consequence
L1 cache reference~1 nsCPU work is never your bottleneck in these rounds
Main-memory reference~100 ns
Read 1 MB from memory~0.25 msin-memory caches feel free
SSD random read~0.1 msdisk is 100–1000× memory — hence caching exists
Read 1 MB from SSD~1 ms
Spinning-disk seek~10 mswhy sequential logs beat random writes (LSM, Kafka)
Round trip, same datacenter~0.5 msa few internal hops per request are fine
Round trip, cross-continent~100–150 msgeo-replication and CDNs are latency decisions, not luxuries

The QPS recipe: a day is ~86,400 s ≈ 10⁵. So events per day ÷ 10⁵ ≈ average QPS, × 2–3 for peak. 100M DAU × 10 reads each = 10⁹/day ≈ 10,000 QPS average, ~30k peak. Storage: items/day × bytes/item × 365 × replication factor. Say the arithmetic out loud — showing the ÷10⁵ trick is itself a signal.

§★ · A REQUIREMENT WALKS IN

The signal router — requirement → component

1. Reads vastly outnumber writes → cache + read replicas; ask how stale is acceptable
2. Traffic is spiky, or a downstream is slow → queue as a buffer; consumers scale independently
3. Data no longer fits one machine → shard — and consistent hashing so growth doesn’t reshuffle everything
4. A machine dying must not lose data → replicate; then CHOOSE: wait for replicas (consistent) or don’t (available)
5. Money moves, or retries exist → idempotency keys + an append-only ledger
6. One event, many interested parties → pub/sub; decide fanout-on-write vs fanout-on-read
7. “Nearby / within radius” queries → geo index (geohash / quadtree), not a WHERE clause
8. Celebrity / hot-key skew → cache the hot set + split the key + jittered expiry
9. Order matters per user/entity → partition by that entity — order within a partition is free
10. Huge counts / uniques, approximately fine → sharded counters, HyperLogLog — exactness is a cost decision

§∞ · RUN THE PROTOCOL ON EACH

Practice ladder

Protocol per design

Read only the requirements → 30-minute attempt on paper (diagram + key decisions) → open the staged model answer one fold at a time → journal (Requirements / Choices / Trade-offs / What I missed) → re-design blank on day +3 and day +10.

§∞ · REQUIREMENT → DESIGN MOVE

Signal drill — flashcards

Each card is a phrase from a real requirements conversation; answer with the design move it should trigger. The deck grows with every set; misses are saved and lead the next shuffle.

signal → move— left
signal

// This lab grows one set at a time — feed it via DESIGN-PROMPT.md and each set arrives with staged model answers, diagrams, ladder entries, flashcards, and journal drills.