System Design Deep Dive
Design systems that scale, and explain why.
Build the mental toolkit for designing large systems: fundamentals, building blocks, data storage and reliability patterns. Then apply it to ten classic case studies and timed mock interviews.
01Fundamentals
The vocabulary and method behind every design.
- The interview framework: requirements → API → design → deep diveA system design interview rewards structure more than clever tricks. Move through requirements, estimates, API, high-level design and deep dives, time-boxing each phase so you finish with a complete, defensible design.11 min
- Back-of-envelope estimationBack-of-envelope estimation turns user numbers into QPS, storage and bandwidth so you can size the system. Rough, rounded numbers are fine; the goal is the right order of magnitude.11 min
- Latency, throughput, availability & SLAsLatency is how long one request takes, throughput is how many requests you handle per second, and availability is the fraction of time the system works. SLAs, SLOs and SLIs turn these into measurable promises.10 min
- Networking & APIs: HTTP, REST, gRPC, WebSocketsClients and services talk over protocols like HTTP, and API styles like REST, gRPC and GraphQL shape those conversations. Choose based on who the client is, how chatty the traffic is and whether the server must push updates.10 min
- Vertical vs horizontal scaling & statelessnessVertical scaling buys a bigger machine; horizontal scaling adds more machines behind a load balancer. Horizontal scaling only works when servers are stateless, so session and user state must live in shared stores.10 min
02Building blocks
The components almost every design is assembled from.
- Load balancers & reverse proxiesA load balancer spreads traffic across healthy servers so no single machine is overwhelmed. Layer 4 balancers route by IP and port; Layer 7 balancers read HTTP and can route by path, header or cookie.11 min
- Caching strategies & CDNsA cache stores hot data in fast memory so repeated reads skip the slower database. The hard parts are choosing a write strategy, keeping data fresh with TTLs and invalidation, and preventing stampedes when hot keys expire.11 min
- Message queues, pub/sub & event streamsMessage queues decouple producers from consumers so work can be buffered, retried and processed asynchronously. A queue hands each message to one worker, while a log like Kafka keeps an ordered, replayable stream many groups can read.10 min
- API gateways & rate limitingAn API gateway is the single front door that handles auth, routing, rate limiting and logging for many services. Rate limiting protects services from abuse and overload using algorithms like token bucket or sliding window.11 min
- Object storage & search indexesDatabases are poor at storing large files and at full-text search. Object storage like S3 holds blobs cheaply and durably, while search engines like Elasticsearch use inverted indexes to find documents by words fast.11 min
03Data storage at scale
Where most of the hard trade-offs live.
- SQL vs NoSQL: relational, key-value, document, wide-column, graphRelational databases offer schemas, joins and transactions; NoSQL families trade some of that for scale or flexibility. Pick the data model that matches your access patterns, not the trendiest technology.12 min
- Replication: leader-follower, multi-leader, leaderlessReplication keeps copies of data on several nodes for availability, durability and read scaling. The models differ in who accepts writes: one leader, several leaders, or any replica.11 min
- Partitioning, sharding & consistent hashingPartitioning, or sharding, splits data across nodes so each holds only part of it. A good shard key spreads load evenly, and consistent hashing lets you add nodes while moving only a small slice of data.12 min
- CAP, PACELC & consistency modelsCAP says that during a network partition a distributed system must choose consistency or availability. PACELC adds that even without partitions you trade latency against consistency. Quorums let you tune where you sit.12 min
- Indexes & storage engines: B-trees vs LSM treesStorage engines decide how data sits on disk. B-trees update pages in place and favour reads; LSM trees buffer writes in memory and flush sorted files, favouring heavy write workloads.12 min
04Reliability & distributed systems
Systems that keep working when things fail.
- Redundancy, failover & multi-regionRedundancy removes single points of failure by running spare copies of every critical component. Failover moves traffic to a healthy copy, either a standby (active-passive) or peers that already serve traffic (active-active).11 min
- Timeouts, retries, backoff & idempotencyNetworks fail, so clients need timeouts and retries. Retries are only safe when operations are idempotent, and they must back off with jitter so a struggling service is not flattened by a retry storm.11 min
- Circuit breakers, bulkheads & backpressureResilience patterns stop one slow or failing dependency from dragging the whole system down. Circuit breakers fail fast, bulkheads isolate resources, and backpressure and load shedding keep overload from spreading.11 min
- Distributed transactions, sagas & outboxWhen one business action spans several services, a single database transaction is no longer possible. Two-phase commit locks everyone and blocks on failures, so most systems use sagas with compensations and the outbox pattern for reliable events.11 min
- Consensus, leader election & distributed locksConsensus lets a group of nodes agree on a value, such as who the leader is, even when some fail. Raft does this with elected leaders and majority votes, and tools like etcd and ZooKeeper package it for coordination.11 min
- Observability, SLOs & error budgetsObservability is the ability to understand what a system is doing from its outputs. Metrics, logs and traces answer different questions, while SLOs and error budgets turn reliability into a clear rule for when to ship or slow down.11 min
05Case studies I: classic services
The questions interviewers ask most often.
- URL shortenerA URL shortener maps short codes to long URLs and redirects billions of clicks. It is read-heavy, so the key choices are collision-free ID generation, a fast key-value lookup, aggressive caching and asynchronous analytics.9 min
- Distributed rate limiterA distributed rate limiter enforces limits like 100 requests per minute per user across many API servers. Counters live in a shared low-latency store such as Redis, updated atomically so concurrent requests cannot slip past the limit.13 min
- Distributed key-value storeA Dynamo-style key-value store spreads keys over nodes with consistent hashing, replicates each key to N nodes, and uses tunable quorums. Hinted handoff, anti-entropy and versioning keep it available and convergent through failures.12 min
- Notification systemA notification system accepts events from many services and delivers them via push, email and SMS. Queues per channel decouple sending from third-party providers, while preferences, rate limits, retries and deduplication protect users.11 min
- Search autocompleteSearch autocomplete suggests popular completions as a user types, within about 100 ms. Precompute top-k suggestions per prefix in a trie built offline from query logs, serve it from memory, and cache aggressively.12 min
06Case studies II: large-scale products
Products with hard scale, real-time or media constraints.
- News feedA news feed shows each user recent posts from people they follow. The central choice is fan-out on write (precompute feeds) versus fan-out on read (merge at request time), and most real systems use a hybrid for celebrities.11 min
- Chat systemA chat system delivers messages in real time over persistent WebSocket connections, stores history durably and tracks who is online. The hard parts are routing to the right connection server, ordering per conversation and offline delivery.11 min
- Video streaming platformA video platform ingests uploads, transcodes them into many resolutions and serves small segments from CDNs. Adaptive bitrate streaming lets the player switch quality as bandwidth changes, and storage and egress dominate the cost.11 min
- Ride-sharing serviceA ride-sharing service tracks millions of moving drivers, matches riders to nearby available drivers and manages each trip's lifecycle. Location writes are huge and ephemeral, so they live in memory with a geospatial index.11 min
- Web crawlerA web crawler downloads billions of pages by repeatedly taking URLs from a frontier, fetching them, extracting links and queuing new ones. It must be polite to each host, avoid revisiting duplicates and scale across many workers.11 min
07Mock interviews
Practise out loud until the structure is automatic.
- Timed solo designs with written trade-offsSolo timed designs build the habit of covering every phase within 45 minutes. Writing down the trade-offs you chose, then comparing with reference solutions, shows exactly where your reasoning is thin.11 min
- Peer mock interviewsPeer mock interviews add the pressure and interruptions of a real interviewer. Structured feedback on communication, requirements, design and depth tells you which gaps to fix before trying again.11 min