All posts

51 posts, newest first

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

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

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.

System Design System Design · Batch Processing · Stream Processing

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

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.

System Design System Design · CI/CD · Canary

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

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

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

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

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 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 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

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.

System Design System Design · Saga · 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.

System Design System Design · Service Discovery · Kubernetes

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.

System Design System Design · Testing · Testcontainers

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

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

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

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.

System Design System Design · Cache · Redis

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

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.

System Design System Design · CDN · HTTP Caching

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

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

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

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

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

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

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

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.

System Design System Design · Latency · Throughput

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.

System Design System Design · Load Balancing · Nginx

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

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.

System Design System Design · Microservices · Modular Monolith

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.

System Design System Design · Capacity Planning · Back-of-the-envelope

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

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

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

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

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

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

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

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.

System Design System Design · HTTP · TCP

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

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.

System Design System Design · Scalability · Stateless

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

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

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.

System Design System Design · Architecture · Trade-off

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

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