System Design
Design scalable systems the way senior engineers do — with a repeatable framework, the core building blocks, and full walkthroughs of the most-asked questions.
Getting Started
- Introduction — What system design interviews test, how they are scored, and how to use this guide.
- How to Prepare — A 4-week study plan that moves from concepts to timed mock interviews.
- Delivery Framework — The 45-minute structure: requirements, entities, API, high-level design, deep dives.
- What Interviewers Look For — The grading rubric and how expectations change from mid-level to senior to staff.
- Common Mistakes — The habits that sink interviews — and what to do instead.
Core Concepts
- Networking Essentials — TCP vs UDP, HTTP, WebSockets, load balancers and what actually matters in an interview.
- API Design — REST, GraphQL and RPC; resource modeling, pagination, idempotency and versioning.
- Data Modeling — Choosing a database, designing schemas, and normalizing vs denormalizing.
- Databases — Relational vs NoSQL, ACID, replication, and how to pick and scale a database for your access patterns.
- Database Indexing — B-trees, LSM trees, composite, geospatial and inverted indexes.
- Sharding — Partitioning strategies, choosing a shard key, hot spots and cross-shard queries.
- Consistent Hashing — The hash ring, virtual nodes, and why adding a node only moves 1/N of keys.
- CAP Theorem — Consistency vs availability under partition, and how to pick per feature.
- Replication — Single-leader, multi-leader and leaderless replication, quorums, replication lag and failover.
- Consistency Models — Linearizable, causal, session guarantees and eventual consistency — and which feature needs which.
- Consensus — Quorums, Raft leader election and log replication, split brain, and what consensus costs.
- Gossip & Failure Detection — Heartbeats vs gossip, phi-accrual and SWIM detectors, cluster membership, and when to use a coordinator instead.
- Clocks & Ordering — Clock skew, Lamport and vector clocks, hybrid clocks, TrueTime and ordering events safely.
- Distributed Transactions — The dual-write problem, two-phase commit, the transactional outbox and change data capture.
- Caching — Where to cache, cache-aside vs write-through, eviction, invalidation and stampedes.
- Load Balancers — L4 vs L7, balancing algorithms, health checks, sticky sessions and avoiding a single point of failure.
- Message Queues — Queues vs logs, delivery guarantees, acks, retries, dead-letter queues and backpressure.
- Blob Storage — Object storage, presigned URLs, multipart uploads, and keeping metadata in the database.
- Content Delivery Networks (CDN) — Edge caching, Cache-Control, versioned URLs vs purging, and what belongs on a CDN.
- Rate Limiters — Token bucket and window algorithms, where limits run, and distributed counters in Redis.
- API Gateways — The single front door: routing, auth, rate limits, BFFs, and how a gateway differs from a load balancer.
- Authentication & Authorization — Sessions vs JWTs, OAuth and OIDC, API keys, RBAC/ABAC/ReBAC and where to enforce checks.
- Microservices — Monolith vs microservices, service boundaries, data ownership and sync vs async communication.
- Search Systems — Inverted indexes, analyzers, BM25 and hybrid ranking, sharded clusters, and syncing with CDC.
- Write-Ahead Logging (WAL) — How databases make commits durable and fast: fsync, group commit, checkpoints, replication and CDC.
- Probabilistic Data Structures — Bloom filters, HyperLogLog, Count-Min Sketch, heavy hitters and MinHash.
- Availability & Fault Tolerance — Nines, SLOs and error budgets, redundancy, failover models, multi-region and blast radius.
- Resilience Patterns — Timeouts, retries with jitter, circuit breakers, bulkheads, load shedding and backpressure.
- Observability — Metrics, structured logs, distributed tracing, SLO-based alerting and health checks.
- LLM Inference — Prefill vs decode, the KV cache, continuous batching, and what it means for latency, cost and serving.
- Numbers to Know — Latency, throughput and storage numbers for modern hardware — and quick estimation.
- Back-of-the-Envelope Estimation — A fast method for QPS, storage, bandwidth and memory estimates — and turning them into decisions.
Key Technologies
- Choosing a Technology — Which technology to reach for, by requirement — with sensible defaults and common stacks per question.
- Redis — Caching, distributed locks, leaderboards, rate limiting, pub/sub and streams.
- Elasticsearch — Inverted indexes, mappings, search APIs, cluster architecture and when to use it.
- Kafka — Topics, partitions, consumer groups, ordering, retention and delivery guarantees.
- PostgreSQL — Transactions, isolation levels, indexes, replication and scaling limits.
- Cassandra — Wide-column modeling, partition and clustering keys, tunable consistency.
- DynamoDB — Partition/sort keys, GSIs, capacity modes, transactions and streams.
- MongoDB — Document modeling, embedding vs referencing, replica sets and shard keys.
- Spanner & NewSQL — Globally distributed SQL: Paxos, TrueTime, external consistency and hot-spot-free keys.
- ClickHouse — Columnar OLAP storage, MergeTree, materialized rollups and analytics at scale.
- SQS & RabbitMQ — Task queues vs logs, visibility timeouts, exchanges, DLQs and idempotent workers.
- Apache Flink — Stateful stream processing, windows, event time, watermarks and checkpoints.
- Apache Spark — Large-scale batch processing, shuffles, data skew and where batch fits next to streaming.
- ZooKeeper & etcd — Consensus-backed coordination: leader election, membership, locks and fencing tokens.
- Memcached — A simple multi-threaded cache: client-side sharding, leases, invalidation and Memcached vs Redis.
- Time-Series Databases — Prometheus, InfluxDB and TimescaleDB: series, compression, downsampling and cardinality.
- Vector Databases — Embeddings, ANN indexes (HNSW, IVF, PQ), filtering, hybrid search and RAG.
- Neo4j & Graph Databases — Nodes and relationships, Cypher traversals, and when an edges table is enough.
- Temporal & Workflow Engines — Durable workflows, activities, retries, timers and orchestrated sagas.
- Kubernetes — Pods, deployments, services, probes, rolling updates and autoscaling.
- Amazon S3 — Presigned and multipart uploads, event notifications, storage classes, lifecycle rules and prefix limits.
- Nginx & Envoy — Reverse proxies: TLS termination, L4 vs L7 routing, timeouts, retries, circuit breaking and service meshes.
- gRPC & Protobuf — Internal service-to-service RPC: Protobuf contracts, streaming, HTTP/2 load balancing, deadlines, retries and schema evolution.
- BigQuery & Snowflake — Cloud data warehouses: storage/compute separation, partitioning, ELT, star schemas and lakehouses.
- Bigtable & HBase — Sorted wide-column stores: row-key design, tablets, LSM storage and avoiding hot spots.
Patterns
- Scaling Reads — Indexes, read replicas, caching layers and CDNs — in that order.
- Scaling Writes — Sharding, batching, queues as buffers, and write-optimized storage.
- Caching at Scale — Sharding a cache cluster, replicas and failover, hot keys, cold starts and stampedes.
- Throttling with Rate Limits — Token buckets and sliding windows, shared counters in Redis, and failing open vs closed.
- Handling Large Blobs — Presigned URLs, multipart uploads, CDNs and keeping blobs out of your DB.
- Generating Unique IDs — Auto-increment, UUIDv4 vs v7, Snowflake IDs and range allocation — and public vs internal IDs.
- Ingesting Time-Series Metrics — High-volume ingestion, compressed time blocks, downsampling, retention and the cardinality trap.
- Building Full-Text Search — Inverted indexes, analysis and ranking, syncing with CDC, and sharding a search cluster.
- Safe Retries & Idempotency — Idempotency keys, dedup in consumers, Kafka transactions and the transactional outbox.
- Event Sourcing & Read Models — Events as the source of truth, snapshots, projections and living with eventual consistency.
- Dealing with Contention — Pessimistic and optimistic locking, reservations, and distributed locks.
- Coordinating Workflows with Sagas — Compensating actions, orchestration vs choreography, pivot steps and workflow engines.
- Scheduling Future Work — Finding due jobs efficiently, leases and retries, recurring schedules and time zones.
- Real-time Updates — Polling, long polling, SSE, WebSockets and fanning updates out across servers.
- Booking Time-Slot Inventory — Per-night inventory, booking every night or none, checkout holds and fast availability search.
- Fanning Out to Followers — Fan-out on write vs read, the celebrity problem, feed storage, ranking and deletes.
- Broadcasting with Pub/Sub — Queues vs topics, choosing a broker, ordering keys, delivery guarantees and live fan-out.
- Finding What's Nearby — Geohashes, quadtrees and H3, static places vs moving drivers, and ranking by ETA.
- Merging Concurrent Edits — OT vs CRDTs, per-document session servers, operation logs, snapshots and presence.
- Aggregating Live Event Streams — Windows, event time and watermarks, checkpointed state, hot keys and batch reconciliation.
- Crawling & Large Data Pipelines — Staged pipelines, the frontier, politeness, dedup with Bloom filters and fault tolerance.
- Managing Long-Running Tasks — Async job queues, workers, retries, idempotency and workflow engines.
- Keeping Money Correct — Payment state machines, idempotency, double-entry ledgers, webhooks and reconciliation.
- Multi-Tenancy — Isolation models, tenant-scoped data, partitioning by tenant, noisy neighbors and tiered tenants.
- Zero-Downtime Migrations — Expand and contract, dual writes and CDC, backfills, shadow reads, cutovers and re-sharding.
Question Breakdowns
- Design a URL Shortener — Short code generation (counters vs. a key service), redirects at scale, caching, partitioning and analytics.
- Design Ticketmaster — Seat holds without double-booking, expiring reservations, fair waiting lines and surge traffic.
- Design WhatsApp — Real-time 1:1 and group messaging, delivery receipts, ordering, presence and offline users.
- Design a Rate Limiter — Token bucket vs. sliding windows with memory math, distributed counters, IP vs. user limits.
- Design a News Feed — Fan-out on write vs. read, the celebrity problem, time-sortable IDs and feed ranking.
- Design Uber — Location ingestion, proximity search, consistent driver matching and live maps.
- Design a Web Crawler — Frontier queues, politeness, dedup, crawler traps and checkpointed, fault-tolerant pipelines.
- Design Top-K (Trending) — Counting at scale with windows, heaps, and approximate sketches.
- Design Pastebin — Metadata vs. blob storage, key generation, expiry and caching immutable content.
- Design Instagram — Photo storage and CDNs, read/write separation, sharding and precomputed feeds.
- Design Dropbox — Chunking, delta sync, dedup, conflict handling and notifying every device.
- Design YouTube / Netflix — Upload and transcoding pipelines, adaptive streaming and CDN strategy.
- Design Typeahead — Tries with cached top-k, offline rebuilds, partitioning and client tricks.
- Design Twitter Search — Inverted indexes, sharding by word vs. by tweet, scatter-gather and ranking.
- Design Yelp (Nearby Places) — Geospatial indexing with grids, geohashes and QuadTrees, and sharding the index.
- Design an Ad Click Aggregator — Click logging off the hot path, stream aggregation, dedup with signed impressions and batch reconciliation.
- Design a Distributed Cache — Consistent hashing, O(1) LRU per node, replication and failover, hot keys and the thundering herd.
- Design a Job Scheduler — Finding due work with a two-layer poll, idempotent claims, leases, retries and the top-of-hour spike.
- Design a Payment System — Idempotency at every hop, payment state machines, a double-entry ledger and reconciliation.
- Design ChatGPT Playground — Prompt versions and threads, streaming tokens over SSE, side-by-side runs, quotas and metering.
- Design a CI/CD System — Webhooks to DAGs, pull-based runners with leases, stuck jobs, isolation, caches and tenant fairness.
- Design a Crossword Puzzle Solver — Backtracking with constraint propagation, splitting the search across workers, cancellation and caching.
- Design Online Chess — Rating-based matchmaking, one authoritative server per game, fair clocks, reconnects and spectators.
- Design a Distributed File System — GFS/HDFS: a metadata master, large replicated chunks, leases, record append and re-replication.
- Design Meta Post Privacy — Read-time audience checks, friends-of-friends as set intersection, caching inputs, and every place a post can leak.
- Design Google Calendar — Recurrence rules and exceptions, time zones, invitation fan-out, free/busy and reliable reminders.
- Design Google Maps — Vector tiles on a CDN, contraction hierarchies, live traffic from probes, ETA and re-routing.
- Design a Leaderboard — Sorted sets for rank in O(log n), time-windowed boards, tie-breaking, sharding and approximate ranks.
- Design LeetCode — Async judging, layered sandboxes for untrusted code, contest spikes and penalty-based leaderboards.
- Design an Online Bookstore — Cached catalog and search, carts, reserve-at-checkout inventory and an idempotent checkout saga.
- Design Distributed Counters — Hot-key contention, sharded counters, log-based batching, HyperLogLog and CRDT counters.
- Design a Remote Devbox — Ephemeral compute with persistent volumes, warm pools and prebuilds, idle stop, tunnels and isolation.
- Design Slack — Gateway and channel servers, two-level fan-out, workspace sharding, read markers and huge channels.
- Design a Webhook Delivery System — At-least-once delivery, backoff with jitter, isolating bad endpoints, signatures and SSRF defense.
- Design a Batch Inference System — Chunked batches on spare GPU capacity, continuous batching, exactly one result per request, deadlines.
- Design ML Model Distribution — Bandwidth math, peer-to-peer and tree distribution of weights, integrity, safe activation and rollback.
- Design Sora (Text-to-Video) — Long GPU jobs, tiered fair queues, preemption at checkpoints, failure recovery, safety and CDN delivery.
- Design Smart Grid Device Control — Millions of MQTT devices, unacknowledged commands, closed-loop demand response and owner overrides.
- Design Airbnb — Per-night availability, atomic date-range booking with holds, availability-aware geo search and index freshness.
- Design DoorDash (Food Delivery) — An order state machine for three parties, timed dispatch and batch matching, courier locks, live tracking and ETAs.
- Design Spotify — Fast playback from CDN and origin, licensing and signed URLs, versioned playlist sync and royalty-grade play counts.
- Design Zoom (Video Conferencing) — Control vs. media plane, SFUs and simulcast, UDP and jitter buffers, cascading servers and fast failover.
- Design Figma (Multiplayer) — Property-level last-writer-wins, one server per file, optimistic local edits, journals and checkpoints, presence.
- Design Cash App (P2P Payments) — Atomic ledger transfers without double spending, synchronous fraud checks, external rails and settlement holds.
- Design a Stock Exchange — In-memory order books, single-threaded deterministic matching, a sequencer and replayable log, latency engineering.
- Design a Market Data Feed — Feed arbitration and gap recovery, snapshot + sequenced updates, conflation for slow clients, bars and corrections.
- Design a CDN — Anycast vs. GeoDNS, hashing inside a PoP, tiered caching and origin shielding, cache keys and global purge.
- Design a Distributed Key-Value Store — Consistent hashing, quorums and hinted handoff, conflict resolution, gossip and anti-entropy, LSM storage.
- Design a Distributed Message Queue — Partitioned append-only logs, ISR replication and high-water marks, consumer groups, offsets and delivery guarantees.
- Design Metrics Monitoring & Alerting — Series and cardinality, compressed time-series storage, downsampling, fast queries and alerting that survives outages.
- Design OTA Firmware Updates — A/B partitions and bootloader rollback, code signing, staged rollouts with automatic halts, delta downloads.
- Design an Enterprise Data Platform — Scoping an open-ended prompt, connectors and CDC, versioned datasets, DAG builds, lineage and permission propagation.
- Design a Data Labeling Platform — Leased tasks for human workers, gold tasks, review and consensus, model-assisted labeling and SLAs.
- Design Reddit — Votes as derived scores, the hot formula and precomputed listings, comment trees and "best" sorting.
- Design TikTok (For You Feed) — Candidate generation, ranking and re-ranking, real-time session signals, cold start and instant playback.
- Design a Flash Sale — In-memory stock gates, waiting rooms with admission tokens, no overselling under failover, bots and isolation.
- Design GitHub — Replicated Git repositories on file servers, atomic ref updates, fork networks, clone storms and pull requests.
- Design Gmail — SMTP in and out, spam at the edge, mailboxes sharded by user, per-user search and change-log sync.
- Design a Distributed Lock Service — Consensus, sessions and ephemeral nodes, the lock recipe, fencing tokens and why Redis locks fall short.
- Design Google Docs — Operational transformation vs. CRDTs, one server per document, op log plus snapshots, presence and offline edits.
- Design a Notification System — Priority isolation, preferences and quiet hours, idempotent delivery, campaign throttling and provider failover.
- Design an Online Auction — Atomic bid acceptance, proxy bidding, live price fan-out, ending on time, anti-sniping and hot auctions.
- Design a Chat LLM Serving Platform — Continuous batching, KV-cache affinity, token-based admission control, streaming, cancellation and GPU autoscaling.
- Design Tinder — Geo candidate search, precomputed stacks, Bloom filters against repeats and atomic mutual-match detection.
- Design Facebook Live Comments — SSE fan-out, per-video pub/sub routing, sampling for 10M-viewer streams and history for late joiners.
- Design Strava — Idempotent offline uploads, a GPS processing pipeline, spatial segment matching and best-effort leaderboards.
- Design a Price Tracker — Demand-prioritized crawling under a budget, change-only price history, indexed alert matching and data quality.
- Design Google News — Adaptive ingestion, clustering articles into stories, coverage-based ranking and cached fronts with personalization.