System Design Case Studies
Nineteen complete sample solutions to the most-asked system design interview problems — URL shortener, unique IDs, rate limiter, key-value store, news feed, chat, notifications, typeahead, web crawler, video streaming, ride sharing, ticket booking, payments, file sync, collaborative editing, metrics monitoring, job scheduler, leaderboard and ad-click aggregation — each with requirements, estimates, APIs, data model, architecture, deep dives, trade-offs and interviewer follow-ups.
Each case study follows the same structure you should use in the interview (see the framework):
- Requirements: functional, non-functional, and what's out of scope.
- Estimation: traffic, storage and bandwidth, only to the precision that changes decisions.
- API: the core endpoints or messages.
- Data model: entities, keys, and the store chosen for each.
- High-level design: a diagram and a walkthrough of the main flows.
- Deep dives: the 2–4 hard parts interviewers push on.
- Trade-offs, bottlenecks, failure modes and how the design evolves.
- Interview questions: the follow-ups you're most likely to face, with model answers.
The problems
| # | Problem | Core lessons |
|---|---|---|
| 1 | URL shortener | ID generation, read-heavy caching, redirects |
| 2 | Unique ID generator | Snowflake, clocks, coordination-free IDs |
| 3 | Distributed rate limiter | algorithms, Redis + Lua, multi-region limits |
| 4 | Key-value store | partitioning, replication, quorums, LSM storage |
| 5 | News feed | fan-out on write vs read, celebrities, ranking |
| 6 | Chat (WhatsApp/Slack) | WebSockets, message ordering, delivery receipts, presence |
| 7 | Notification system | multi-channel delivery, preferences, retries, dedup |
| 8 | Typeahead / search autocomplete | tries, top-K, offline aggregation, caching |
| 9 | Web crawler | politeness, URL frontier, dedup, scale |
| 10 | Video streaming (YouTube/Netflix) | upload pipeline, transcoding, adaptive bitrate, CDN |
| 11 | Ride sharing (Uber) | geo-indexing, matching, location updates, surge |
| 12 | Ticket booking (Ticketmaster) | seat holds, contention, virtual waiting room |
| 13 | Payment system | ledgers, idempotency, reconciliation, PSPs |
| 14 | File sync (Dropbox/Drive) | chunking, dedup, sync protocol, conflicts |
| 15 | Collaborative editor (Google Docs) | OT vs CRDT, presence, document sessions |
| 16 | Metrics & monitoring | time-series ingestion, storage, alerting |
| 17 | Distributed job scheduler | durable timers, leases, exactly-once-ish execution |
| 18 | Real-time leaderboard | sorted sets, sharding ranks, approximate ranking |
| 19 | Ad-click aggregator | stream processing, windowing, exactly-once, reconciliation |
Chapters
In recommended orderThe classic warm-up. Short-code generation strategies (hash, counter + base62, pre-generated keys), a read-heavy redirect path with caching, 301 vs 302, analytics via an event stream, custom aliases, expiry, and abuse prevention.
5 Q
Generate billions of unique, roughly time-ordered 64-bit IDs across many machines without coordination — UUID v4/v7, database sequences and ticket servers, range allocation, Twitter Snowflake bit layout, worker-ID assignment, clock skew and rollback handling, and the trade-offs between them.
4 Q
A rate-limiting service for an API platform handling millions of requests per second — rules and configuration, placement (gateway, sidecar, library), the algorithm choice, atomic Redis implementation, latency budgets, fail-open vs fail-closed, local batching and approximate limits, multi-region limits, and observability.
5 Q
Build a highly available, partition-tolerant key-value store — consistent hashing with virtual nodes, replication and preference lists, tunable quorums, versioning and conflict resolution with vector clocks or LWW, sloppy quorums and hinted handoff, anti-entropy with Merkle trees, gossip membership, and an LSM-tree storage engine.
5 Q
Post creation and home timelines for hundreds of millions of users — fan-out on write vs fan-out on read, the hybrid approach for celebrities, timeline caches in Redis, media handling, ranking pipelines, pagination with cursors, counters for likes, and the hot-key problems of viral content.
5 Q
Real-time 1:1 and group messaging at billions of messages per day — persistent WebSocket gateways and connection routing, message flow with server acks and delivery/read receipts, per-conversation ordering with sequence numbers, offline delivery and sync, group fan-out, presence, push notifications, media, and end-to-end encryption.
5 Q
A multi-channel notification platform (push, SMS, email, in-app) used by every product team — event ingestion, user preferences and quiet hours, templating and localisation, priority queues per channel, provider integrations with retries and failover, deduplication, rate limiting and digests, scheduled and bulk campaigns, delivery tracking and analytics.
5 Q
Return the top suggestions for a prefix within ~50 ms for millions of keystrokes per second — tries with precomputed top-K per node, the offline aggregation pipeline for query frequencies, sharding the trie, multi-layer caching (browser, CDN, service), freshness for trending queries, personalisation, and filtering.
5 Q
Crawl billions of pages politely and efficiently — the URL frontier with priority and per-host politeness queues, DNS caching, fetching at scale, robots.txt, URL normalisation and URL-seen dedup with Bloom filters, content dedup with fingerprints (SimHash), traps and spam, recrawl scheduling for freshness, and distributing the crawl.
5 Q
Upload, process and stream video to hundreds of millions of viewers — resumable uploads, the transcoding pipeline as a DAG of parallel chunk jobs, codecs and bitrate ladders, HLS/DASH adaptive bitrate streaming, CDN strategy (including Netflix Open Connect), metadata and view counts, live streaming differences, and cost control.
5 Q
Real-time matching of riders and drivers — high-frequency location ingestion, in-memory geospatial indexing (geohash/H3), the dispatch/matching service and offer flow, trip state machine, ETA and routing, surge pricing from supply/demand per cell, payments, and consistency for "one driver, one trip".
5 Q
Selling limited seats under extreme contention — event and seat-map modelling, temporary seat holds with TTLs, preventing double booking (conditional updates, row locks, Redis holds), the booking state machine with payment, the virtual waiting room for on-sales, bots and fairness, caching seat availability, and recovering from abandoned holds.
5 Q
Moving money correctly — the payment lifecycle (authorise, capture, refund), integrating payment service providers and card networks, idempotency end to end, double-entry ledgers, the payment state machine, webhooks and asynchronous outcomes, reconciliation with settlement files, retries without double charging, PCI scope reduction, fraud checks, and payouts.
6 Q
Store files for hundreds of millions of users and keep every device in sync — chunking with content-defined boundaries, content-addressed dedup, block storage vs metadata service, the sync protocol with a per-user change journal, notifications via long polling, conflict handling, versioning, sharing and permissions, and bandwidth optimisations.
5 Q
Many people editing the same document in real time — why naive last-write-wins fails, operational transformation with a central server, CRDTs for decentralised merging, the document session service and routing all editors of a doc to one owner, cursors and presence, persistence with operation logs and snapshots, offline editing, comments, permissions and version history.
5 Q
Collect, store, query and alert on hundreds of millions of time series — push vs pull collection, the time-series data model and cardinality, ingestion through Kafka, time-series storage with Gorilla compression, downsampling and retention tiers, the query engine, the alerting pipeline with deduplication and routing, and meta-monitoring.
5 Q
Run millions of scheduled and delayed jobs reliably — job definitions and cron parsing, storing next-run times efficiently (time-bucketed tables, sorted sets, timing wheels), leasing and visibility timeouts so each run executes once, worker pools and queues, retries and idempotency, priorities and fairness across tenants, long-running workflows, and observability.
5 Q
Rank hundreds of millions of players in real time — Redis sorted sets and their complexity, score updates and tie-breaking, top-N and "my rank ± neighbours" queries, time-windowed (daily/weekly) boards, sharding when one sorted set isn't enough (score-range partitioning, approximate ranks via histograms), friends leaderboards, durability and anti-cheat.
5 Q
Count billions of ad clicks per day per ad per minute for billing and dashboards — click ingestion and redirect, deduplication and fraud filtering, stream processing with event-time windows and watermarks, exactly-once aggregation, the OLAP store for queries, hot ads, lambda-style reconciliation with batch, and correctness for money-relevant data.
5 Q