HLD case studies¶
Each case study follows the same spine: requirements, estimation, API, data model, v1 design, 3-5 deep dives, scaling, trade-offs and a 45-minute pacing table. Start with the P0 systems; they cover the archetypes (read-heavy fan-out, real-time stateful, contended inventory, partitioned key-value storage) that the P1 and P2 systems are variations of. Every study ships one key Python snippet under code/hld/ with tests, so you can see the crux - fan-out, seat holds, matching, the ledger - as running code rather than a box on a diagram.
Tiers: P0 must be solid before any interview, P1 is expected of a strong SDE2, P2 is stretch material for when the rest is done.
Start here (P0)¶
- Design a URL shortener
- Design a distributed rate limiter
- Design a Dynamo-style key-value store
- Design a distributed unique ID generator
- Design a news feed
- Design a chat system
- Design YouTube or Netflix
- Design Uber (with a DoorDash variant)
- Design Ticketmaster (with a hotel-booking variant)
All pages¶
| # | Page | Tier | Covers |
|---|---|---|---|
| 1 | Design a URL shortener | P0 | TinyURL/Bitly with a Pastebin variant. Cruxes: ID generation (counter or Snowflake to base62 vs hash prefix + collision retry); 301 vs 302… |
| 2 | Design a distributed rate limiter | P0 | Cruxes: algorithm choice (memory vs accuracy); placement (gateway middleware vs sidecar); distributed counters (Redis Lua atomicity, race… |
| 3 | Design a Dynamo-style key-value store | P0 | Cruxes: consistent-hash partitioning + preference lists; tunable N/W/R quorums; versioning with vector clocks or LWW and read repair… |
| 4 | Design a distributed unique ID generator | P0 | Cruxes: requirements (64-bit, k-sortable, unique, high QPS); options (UUID, DB auto-increment, ticket server, Snowflake); clock skew and… |
| 5 | Design a news feed | P0 | Twitter/Facebook/Instagram. Cruxes: fan-out on write vs read vs hybrid (celebrity problem); feed cache structure (per-user ID list, post… |
| 6 | Design a chat system | P0 | WhatsApp/Messenger/Slack. Cruxes: WebSocket connection management + session registry (which server holds a user); per-conversation ordering… |
| 7 | Design YouTube or Netflix | P0 | Cruxes: resumable multipart upload with presigned URLs; transcoding DAG (split by GOP, parallel encodes, codecs and resolutions); adaptive… |
| 8 | Design Uber (with a DoorDash variant) | P0 | Cruxes: location ingestion at scale (WebSocket or UDP to Kafka to in-memory geo index by geohash/H3); matching (nearest-K with radius… |
| 9 | Design Ticketmaster (with a hotel-booking variant) | P0 | Ticketmaster/BookMyShow with Airbnb/hotel variant. Cruxes: seat hold with TTL + optimistic locking vs SELECT FOR UPDATE vs Redis lock… |
| 10 | Design a web crawler | P1 | Cruxes: URL frontier with priority + politeness (per-host queues, delays); dedup (URL-seen Bloom filter, content SimHash); robots.txt, DNS… |
| 11 | Design a notification system | P1 | Push/SMS/email. Cruxes: channel abstraction + provider fan-out (APNs, FCM, Twilio, SES); reliability (queue per channel, retries, DLQ)… |
| 12 | Design typeahead autocomplete | P1 | Cruxes: trie with per-node cached top-K; offline data-gathering pipeline (logs, aggregate, rebuild); trie sharding by prefix and serving… |
| 13 | Design Dropbox or Google Drive | P1 | Cruxes: chunking (fixed vs content-defined) + dedup; delta sync (changed chunks only); metadata DB (file-to-chunk manifest, versions) with… |
| 14 | Design Yelp (proximity service) | P1 | Cruxes: index choice (geohash vs quadtree vs S2); radius search via cell + neighbors then haversine filter; read-heavy caching by cell and… |
| 15 | Design Nearby Friends | P1 | Cruxes: frequent location updates over WebSocket; pub/sub fan-out to friends' channels (Redis pub/sub); location cache with TTL; scaling… |
| 16 | Design a payment system and digital wallet | P1 | Cruxes: idempotency for money movement; payment state machine + PSP (Stripe) integration + webhooks (out-of-order, retries, signatures)… |
| 17 | Design a distributed message queue | P1 | Kafka-like. Cruxes: append-only segmented log + sequential IO + page cache; partitions and keys for ordering, consumer groups + offsets… |
| 18 | Design a metrics monitoring and alerting system | P1 | With a log-aggregation (ELK) variant. Cruxes: data model (metric + labels, time series) and cardinality explosion; ingestion push vs pull… |
| 19 | Design an ad click aggregation system | P1 | Cruxes: per-ad per-minute counts + top-N via stream processing; exactly-once and dedup (event IDs, Kafka transactions); late events +… |
| 20 | Design a Top-K heavy hitters service | P1 | Trending topics, top videos. Cruxes: exact hash map vs CMS + heap; windowing (per-minute buckets merged for 1h and 24h); partition by key… |
| 21 | Design a real-time gaming leaderboard | P1 | Cruxes: Redis sorted set operations and complexity; sharding beyond one node (by user + scatter-gather vs by score range); real-time rank… |
| 22 | Design a distributed cache | P1 | Redis/Memcached-like. Cruxes: sharding with consistent hashing, client vs proxy routing; eviction + TTL (lazy vs active expiry)… |
| 23 | Design S3 (with a GFS/HDFS variant) | P1 | Cruxes: metadata service (bucket and object tables, partitioning) vs data service; durability (replication vs erasure coding, checksums… |
| 24 | Design Google Docs | P1 | Cruxes: OT with central sequencing vs CRDT (RGA), pick and justify; WebSocket transport + operation broadcast; operation log + snapshots… |
| 25 | Design a distributed job scheduler | P1 | Cruxes: data model (job, schedule, run) + next_run_time index polling vs time wheel; no double execution (leader or partitioned schedulers… |
| 26 | Design Amazon (e-commerce with inventory and flash sales) | P1 | Cruxes: catalog and search read path; cart (Redis or DynamoDB, guest merge); inventory reservation with TTL and oversell prevention (atomic… |
| 27 | Design Twitch (live streaming with live comments) | P1 | Cruxes: ingest (RTMP/SRT), transcode, segment (HLS, LL-HLS, WebRTC) latency tiers; CDN distribution; live comments fan-out (per-stream… |
| 28 | Design a search engine (with Twitter real-time search) | P2 | Cruxes: crawl-to-index pipeline (MapReduce inverted-index build); sharding by document vs term; scatter-gather serving, top-K merge… |
| 29 | Design Gmail | P2 | Cruxes: mailbox storage partitioned by user; send and receive (SMTP gateways, MTA retries); per-user search index; threading via… |
| 30 | Design a stock exchange | P2 | Cruxes: matching engine (price-time priority order book, single-threaded per symbol); sequencer + deterministic replay for fault tolerance… |
| 31 | Design LeetCode (online judge) | P2 | Cruxes: submission queue + worker pool; sandboxing (containers, seccomp, cgroups, time and memory limits, no network); test-case storage +… |