51 posts

System Design

The System Design series starts from the journey of a request and capacity estimates, then works up through caching, sharding, replication, consensus, message queues, reliability, and full design problems. The reading order is in the series map in Part 0.

Prerequisites: you have built a web API with Spring Boot and used MySQL; you do not need to know Redis or message queues yet. The series has 51 posts of about 11 to 28 minutes each. The series map and the full reading guide are in Part 0 How to Think About System Design.

Beginner path: Part 0 → Part 1 → Part 2 → the first four posts of Part 3 (up to 3-4 Transactions and Isolation Levels) → 6-2 Timeouts and Retries and 6-3 Circuit Breakers → any problem from Part 9, of which 9-1 URL Shortener is the easiest start. When you read a single post, first read the posts in its “Read first” line at the top; a post without that line has no particular prerequisite.

On-call path (if you are on call or run production systems): 6-1 Redundancy and Failover → 6-2 Timeouts and Retries → 6-3 Circuit Breakers → 6-4 Rate Limiting → 6-5 Observability, then HikariCP connection pool tuning in the Database category. To have an LLM agent help with on-call, continue with 5-1 Exception Handling and Recovery and 6-2 Designing an On-Call Incident Assistant from the Agent series. More on-call posts are under the On-call tag.

Part 0 Introduction 1 post

Part 1 Measurement basics 3 posts

Part 2 From one machine to many 4 posts

Part 3 Storage basics 8 posts

SQL vs NoSQL: Choose a Database by Access Pattern, Not by Buzzword

System Design series Part 3-1: the trade-offs of five data models, why NoSQL is fast and what it costs, and MySQL JSON columns and partitioning to delay a new database.

System Design System Design · SQL · NoSQL

Indexes and B+Trees: From Disk Pages to Composite Indexes, Index-Defeating Queries, and Keyset Pagination

System Design series Part 3-2: why three B+Tree levels hold 100M rows, clustered vs secondary indexes, leftmost prefixes, index-defeating SQL, write costs, keyset paging.

System Design System Design · Index · B+Tree

B-Tree vs LSM-Tree: In-Place Updates vs Append-Only, and the Write, Read, and Space Amplification Trade-offs

System Design series Part 3-3: B+Tree in-place updates vs LSM-Tree appends, three amplifications simulated for tiering and leveling, tombstone traps, and delete vs erase.

System Design System Design · LSM-Tree · B+Tree

Transactions and Isolation Levels: MVCC, Lost Updates, Write Skew, and Spring Transaction Boundaries

System Design series Part 3-4: lost update and write skew in sign-ups; conditional UPDATE, locks, unique constraints; isolation levels by database; Spring transactions.

System Design System Design · Transaction · Isolation Level

File and Object Storage: Block vs File vs Object, Direct Multipart Uploads, Metadata Consistency, and Upload Security

System Design series Part 3-5: block, file, and object storage, how object stores scale, direct multipart uploads, keeping DB and files consistent, and upload security.

System Design System Design · Object Storage · S3

Bloom Filters and HyperLogLog: Trading a Little Error for a Lot of Memory, and What to Do When Someone Games the Estimate

System Design series Part 3-6: Bloom filter error vs capacity, HyperLogLog error and merging, cache penetration, unique visitors, and count inflation via a public hash.

System Design System Design · Bloom Filter · HyperLogLog

Full-Text Search and Inverted Indexes: Chinese Tokenization, BM25 Ranking, Index Sync, and the Authorization Boundary of Search

System Design series Part 3-7: beyond LIKE, an inverted index with Chinese bigram traps and BM25, MySQL FULLTEXT vs Elasticsearch, index sync, and search authorization.

System Design System Design · Full-Text Search · Inverted Index

Geohash and Geospatial Indexes: Cell Boundaries in Nearby Search, Redis GEO, and How Distance Leaks Location

System Design series Part 3-8: Geohash makes coordinates searchable by a B+Tree; cell boundaries, 9-cell queries, Redis GEO vs MySQL SPATIAL vs H3, and trilateration.

System Design System Design · Geohash · Geospatial

Part 4 Distributed data 7 posts

Replication and Replication Lag: Why Users Cannot Read What They Just Wrote After Read/Write Splitting

System Design series Part 4-1: simulating four read routings under lag spikes, Spring read/write splitting, read-your-writes with GTIDs, and stale permission checks.

System Design System Design · Replication · MySQL

Sharding: Choosing a Shard Key, Moving Data When You Reshard, and What You Lose Across Shards

System Design series Part 4-2: shard key skew, resharding cost, and fan-out latency simulated; sign-ups sharded by talk in Spring with an outbox index; tenant isolation.

System Design System Design · Sharding · Partitioning

Consistent Hashing: Moving Only 1/N When Nodes Change, Virtual Nodes, Rendezvous Hashing, and Deliberately Chosen Keys

System Design series Part 4-3: key movement and load with hash rings, virtual nodes, and rendezvous hashing, Guava cache routing and work assignment, and crafted keys.

System Design System Design · Consistent Hashing · Rendezvous Hashing

Distributed IDs: UUIDv7, Snowflake, and Segment Allocation, Compared on Order, Size, and What They Leak

System Design series Part 4-4: a simulation of random vs time-ordered keys in a B+Tree, UUIDv7 vs Snowflake vs segment allocation, and what public IDs leak.

System Design System Design · Distributed ID · UUIDv7

CAP and PACELC: Consistency or Availability During a Partition, Latency or Consistency Otherwise

System Design series Part 4-5: the real CAP and PACELC trade-offs, a simulated cross-site quorum, per-feature Cassandra consistency, and authorization in a partition.

System Design System Design · CAP · PACELC

Consensus and Raft: Elections, Log Replication, Read Consistency, and Leader Election with etcd

System Design series Part 4-6: Raft elections, log replication, and safety; majorities, linearizable reads, membership changes; running a job on one instance with etcd.

System Design System Design · Consensus · Raft

Distributed Locks and Fencing Tokens: The Lock Expires, and the Holder Does Not Know

System Design series Part 4-7: why lease locks fail in GC pauses and failover; Redis, Redlock, databases, etcd compared; fencing tokens and idempotency keys for payouts.

System Design System Design · Distributed Lock · Fencing Token

Part 5 Service communication 5 posts

REST, gRPC, and GraphQL: Choosing an API Style by Caller

System Design series Part 5-1: compare REST, gRPC, and GraphQL on contracts, caching, streaming, and debugging; pick by caller; handle deadlines, N+1, and query depth.

System Design System Design · REST · gRPC

Message Queues: Decoupling, Peak Shaving, Retries, and Why Messages Will Be Duplicated

System Design series Part 5-2: queues to decouple, shave peaks, and retry; acks and duplicates, DLQs, ordering, dual writes, with RabbitMQ quorum queues and Spring AMQP.

System Design System Design · Message Queue · RabbitMQ

Pub/Sub and Delivery Semantics: Kafka Partitions, Consumer Groups, and What Exactly-Once Really Guarantees

System Design series Part 5-3: Pub/Sub in RabbitMQ vs Kafka, what at-least-once and exactly-once mean, partition ordering, consumer groups, DLTs, idempotent consumers.

System Design System Design · Pub/Sub · Kafka

Idempotency and Idempotency Keys: Making Retries Safe

System Design series Part 5-4: retries that double sign-ups and charges; unique keys, conditional updates, Idempotency-Key; concurrency, fingerprints, expiry, key scope.

System Design System Design · Idempotency · REST

Real-Time Updates: Choosing Between Polling, Long Polling, SSE, and WebSocket, and Pushing from Many Servers

System Design series Part 5-5: polling, long polling, SSE, WebSocket compared; multi-server fan-out, conflation, reconnect gaps, Origin checks, per-message authorization.

System Design System Design · SSE · WebSocket

Part 6 Reliability 5 posts

Redundancy, Failover, and Disaster Recovery: From Availability Numbers to Restore Drills

System Design series Part 6-1: availability math, RPO, and RTO for redundancy; the four failover steps; why replication is not a backup; restore drills and ransomware.

System Design System Design · High Availability · Failover

Timeouts, Retries, Backoff, and Jitter: How Retries Save a System, and How They Bring It Down

System Design series Part 6-2: timeouts and timeout budgets, which errors to retry, backoff, jitter, and retry budgets against retry storms, with Spring 7 @Retryable.

System Design System Design · Timeout · Retry

Circuit Breakers and Bulkheads: Keep One Broken Downstream from Taking Down the Whole System

System Design series Part 6-3: circuit breakers fail fast and fall back when a downstream fails, bulkheads stop cascading failures, in Resilience4j and @ConcurrencyLimit.

System Design System Design · Circuit Breaker · Bulkhead

Rate Limiting: Algorithms, Distributed Rate Limiting, and How It Differs from Load Shedding

System Design series Part 6-4: fixed window, sliding window, and token bucket compared, distributed limits, keys and 429s, versus load shedding, and a Redis Lua script.

System Design System Design · Rate Limiting · Token Bucket

Observability: Metrics, Logs, Traces, and SLOs, from 'It Seems Slow' to Finding the Cause

System Design series Part 6-5: find problems with metrics, logs, and traces; cardinality explosions, sampling, SLO burn-rate alerts, and audit log and telemetry security.

System Design System Design · Observability · OpenTelemetry

Part 7 Architecture evolution 4 posts

Part 8 Security 5 posts

Authentication: Sessions, Tokens, OAuth 2.0/OIDC, and Where Login State Should Live

System Design series Part 8-1: sessions vs tokens on revocation and scaling, OAuth 2.0/OIDC code flow and PKCE, browser BFFs, passwords, passkeys, and common attacks.

System Design System Design · Authentication · OAuth 2.0

Authorization Models and the OWASP API Top 10: What You Can Do After Logging In

System Design series Part 8-2: function, object, and property-level authorization, RBAC vs ABAC vs ReBAC, where checks go, BOLA and SSRF defenses, the OWASP API Top 10.

System Design System Design · Authorization · OWASP

After BOLA Gets Past the BFF: How Microservices Pass Along Who Is Calling and for Whom

System Design series Part 8-3: inside the network, prove the calling service with mTLS, pass the user via token exchange and Transaction Tokens, avoid confused deputies.

System Design System Design · Microservices · mTLS

Encryption in Transit and at Rest, and Secrets Management: What Encryption Protects Depends on Who Can Get the Key

System Design series Part 8-4: what TLS, storage-layer, and field encryption each stop; envelope encryption, AEAD, key rotation, and managing DB passwords and API keys.

System Design System Design · Encryption · KMS

Abuse Prevention: Making Scalping, Credential Stuffing, and Fake Accounts Unprofitable for Adversaries Who Adapt

System Design series Part 8-5: scalping, credential stuffing, fake accounts, SMS pumping; multi-key rate limits, risk-based step-up, lotteries, and a detect-respond loop.

System Design System Design · Bot Protection · Fraud Prevention

Part 9 Design problems 7 posts

Design Problem: A URL Shortener, from Estimates and Code Generation to Phishing Abuse

System Design series Part 9-1: a URL shortener from estimates; code generation, 301 vs 302, caching, click stats, cross-region lag, STRIDE for phishing and enumeration.

System Design System Design · URL Shortener · Cache

Design Problem: A News Feed, Push vs Pull, and the Celebrity Problem

System Design series Part 9-2: push vs pull costs for a speaker feed, a hybrid for celebrities, timeline storage, cursor paging, visibility checks, and a threat model.

System Design System Design · News Feed · Redis

Design Problem: A Chat System, Where Direct Messages and a 50,000-Person Live Chat Room Are Two Different Problems

System Design series Part 9-3: DMs and live chat: per-conversation sequence numbers, client message IDs, offline sync, unread counts, batched pushes, and a threat model.

System Design System Design · Chat · WebSocket

Design Problem: Flash Sale Ticketing, and How Much Each Layer Must Turn Away When 500,000 People Chase 10,000 Seats

System Design series Part 9-4: the intro's sign-ups as a flash sale. CDN, waiting room, Redis reservation, async writes cut load; the DB stops overselling. Threat model.

System Design System Design · Flash Sale · Redis

Design Problem: A Notification System Where Verification Codes Cannot Wait Behind 10 Million Newsletters

System Design series Part 9-5: multichannel notifications: queues and domains split by priority, dedup, quiet hours, dead push tokens, bounces, unsubscribe, threat model.

System Design System Design · Notification · Kafka

Design Problem: A Leaderboard, with Ranks for Ten Million Members, Who Comes First in a Tie, and Time Decay for Trending Talks

System Design series Part 9-6: a weekly leaderboard for 10M members on a Redis sorted set, first-to-reach tie-breaks, a rebuildable ledger, and decaying trending talks.

System Design System Design · Leaderboard · Redis

Design Problem: A Distributed Scheduler, Where a Million Delayed Tasks Must Each Run Only Once, at the Right Time

System Design series Part 9-7: delayed tasks like payment deadlines and reminders: SKIP LOCKED, leases and claim IDs, retries, jitter, missed runs, and a threat model.

System Design System Design · Scheduler · Delayed Task

Part 10 Delivery 2 posts