System Design
51 posts
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.
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.
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.
Batch and Stream: Monthly Settlement Reports and a Live Trending List, Two Ways to Process Data
System Design series Part 7-4: batch vs stream, restartable chunked batches, event time, windows and late data, Lambda and Kappa, using Spring Batch and Kafka Streams.
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.
CI/CD and Deployment Strategies: Old and New Versions Run Side by Side, So Design Changes for It
System Design series Part 10-2: build-once pipelines, rolling vs blue-green vs canary, expand–contract schema changes, canary analysis, flags, and supply chain security.
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.
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.
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.
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.
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.
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.
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.
Sagas and the Outbox Pattern: Keeping a Cross-Service Flow Consistent Without Distributed Transactions
System Design series Part 7-3: sagas instead of distributed transactions, choreography vs orchestration, compensation, pivot steps, isolation anomalies, timeouts, outbox.
Service Discovery: How Services Find Each Other, and What Happens When an Instance Disappears
System Design series Part 7-2: client-side, server-side, DNS, and service mesh discovery; registration, health checks, stale data, Pod shutdown order, registry spoofing.
Testing at Scale: End-to-End Tests Cannot Carry Thirty Services
System Design series Part 10-1: why end-to-end tests fall short at 30 services; real-dependency integration, contract, open-model load, fault, and authorization tests.
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.
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.
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.
Caching in Depth: Hit Ratio Math, Write-Order Races, Penetration, Breakdown, Avalanche, and Multi-Level Caches
System Design series Part 2-3: hit ratio math, cache-aside write races, penetration, breakdown, avalanche, hot keys, multi-level caches, and evict-after-commit in Spring.
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.
CDNs and HTTP Caching: Cache-Control, Versioned Assets, Edge Caching, and Cache Attacks
System Design series Part 2-4: how CDNs cut latency and origin bandwidth, Cache-Control, ETag and 304, versioned assets, API micro-caching, cache deception and poisoning.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Latency, Throughput, and p99: Stop Looking at Averages and Size Thread and Connection Pools with Little's Law
System Design series Part 1-2: latency, throughput, percentiles, why averages lie, how fan-out grows the tail, why utilization cannot max out, and Little's Law for pools.
Load Balancing in Depth: L4 and L7, Algorithms, Health Checks, and Connection Draining
System Design series Part 2-2: L4 vs L7, a simulation of Round Robin, P2C, and Least Outstanding on a slow node, non-cascading health checks, keep-alive, and draining.
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.
Monolith vs Microservices: Get the Boundaries Right Before You Decide Whether to Split
System Design series Part 7-1: what monoliths, modular monoliths, and microservices cost; capability boundaries, data ownership, distributed monoliths, Spring Modulith.
Napkin Math for Capacity Estimates: Latency Numbers and Simple Arithmetic for Machine Counts and Storage
System Design series Part 1-3: conversions and latency numbers, then peak QPS, machines, storage, and bandwidth from daily active users, with a runnable Java estimator.
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.
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.
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.
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.
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.
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.
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.
The Journey of an HTTP Request: Timing Every Leg from DNS, TCP, and TLS Through the Load Balancer to the Database
System Design series Part 1-1: timing an HTTPS request from DNS and TCP/TLS to the LB, Spring Boot, and MySQL, why code cannot fix cross-region latency, and what does.
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.
Vertical Scaling, Horizontal Scaling, and Stateless Services: Where Sessions, Files, Scheduled Jobs, and Local State Should Go
System Design series Part 2-1: scale up vs scale out, state hidden in your app, and moving it out with Spring Session, ShedLock, S3 presigned URLs, and graceful shutdown.
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.
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.
How to Think About System Design: Requirements, Estimates, Trade-offs, and HLD/LLD
System Design series intro: clarify requirements, estimate load, find the real bottleneck, and record the trade-off in an ADR for an event sign-up system. Includes the series map.
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.
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.