skip to content
jaeaeichsysdes

system design

First-principles notes and clean whiteboard architectures built to read once and remember.15 fundamentals with interactive labs and 14 end-to-end case studies with Excalidraw whiteboards.

building blocks

5
  1. 01Back-of-the-Envelope Math

    Powers-of-10 shortcuts, visual latency scales, and single-node limits so you can estimate QPS, storage, and sharding thresholds in seconds without rote memorization.

  2. 02Distributed Unique IDs

    Deriving every distributed ID generator from three first-principles mechanisms: coordination, probability, and partitioning space and time.

  3. 03Rate Limiting

    Deriving production rate limiters from first principles: why naive counters allow 2× boundary spikes, how token buckets and sliding counters bound bursts, and how Redis Lua fixes distributed race conditions.

  4. 04Consistent Hashing

    Deriving consistent hashing from first principles: why modulo sharding causes cache-miss avalanches, how a hash ring bounds key movement to 1/N, and why virtual nodes eliminate hotspot skew.

  5. 05Bloom Filters

    Deriving Bloom filters from first principles: trading exact storage for a compact bit array that answers 'definitely absent' with zero false negatives, why deletion breaks, and how LSM engines skip disk reads.

storage

4
  1. 01B-Trees vs LSM-Trees

    Deriving the two dominant database storage engines from disk physics: in-place random page updates versus append-only sorted runs and compaction.

  2. 02Caching & Failure Modes

    From memory hierarchy latency to Cache-Aside, Write-Through, and surviving the three production cache outages: thundering herd, penetration, and avalanche.

  3. 03Replication & Quorums

    Why databases replicate, the anomalies caused by replication lag, and how Dynamo-style W + R > N quorum math trades latency and availability for freshness.

  4. 04Sharding & Hotkeys

    Horizontal partitioning from first principles: range vs hash sharding, why cross-shard joins hurt, and mitigating celebrity hotkeys with key salting.

coordination

4
  1. 01Concurrency & Failure Modes

    The 12 classic concurrency and distributed-systems bugs unified under one root cause (TOCTOU): state changes in the gap between check and use.

  2. 02Distributed Locks & Fencing Tokens

    Why TTL leases alone cannot guarantee mutual exclusion under GC pauses or network delays, and how monotonic fencing tokens enforced by storage prevent zombie writes.

  3. 03Idempotency, Retries & Transactional Outbox

    Why networks force at-least-once delivery, how Idempotency-Key deduplication stops double charges, and how the transactional outbox eliminates DB-plus-Kafka dual writes.

  4. 04Consensus, Quorums & Raft

    Deriving majority quorums from first principles, how Raft uses monotonic terms and log matching to prevent split-brain, and why clusters run 3 or 5 nodes — never 2 or 4.

messaging & traffic

2
  1. 01Queues vs Event Logs

    Deriving work queues and partitioned event logs from first principles: competing consumers, consumer groups, offsets, replay, and backpressure.

  2. 02Load Balancing & Circuit Breakers

    Routing traffic past slow nodes with Power of Two Choices and stopping cascading failures with circuit breakers, timeouts, and bulkheads.

case studies

14
  1. 01Design a URL Shortener

    End-to-end architecture for a 1B DAU URL shortener: Snowflake + Base62 codes, DynamoDB conditional writes, CDC-backed Bloom filters, and sub-10ms multi-tier caching.

  2. 02Design a Distributed Rate Limiter

    End-to-end architecture for a 1M peak RPS rate limiter across 500 stateless API gateways: decoupled rule control plane, atomic Lua token buckets on 20 Redis shards, and fail-open/closed policies.

  3. 03Design a Distributed Job Scheduler

    End-to-end architecture for 50K job triggers/sec: sharded Postgres with CDC outbox, RabbitMQ work queues, Kubernetes execution nodes, optimistic-locked retries, and Glacier archival.

  4. 04Design a Metrics & Alerting System

    Real-time observability at 500K–2M metrics/sec (Datadog / Prometheus at scale): batched Kafka ingestion, ClickHouse MergeTree rollups, Flink DDSketch p99 alerting, and state-machine deduplication.

  5. 05Design a Real-Time Chat System

    WhatsApp / Discord at 100M DAU and 10M concurrent WebSockets: L4 stateful gateways, user-keyed multi-device routing, DynamoDB cursor pagination, watermark read receipts, and S3 presigned media.

  6. 06Design Ticketmaster (Event Booking)

    Handling 1M concurrent users during hot ticket drops: split AP browse/search and CP seat booking, Redis 6 KB stadium bitmaps, atomic 10-minute Lua holds, conditional DB commits, and auto-refunds.

  7. 07Design Ride-Hailing (Uber / Lyft)

    Geospatial matching at 1M active drivers (250K GPS writes/sec): region-sharded Redis GEO indexes, separate alive-TTL filtering, sequential 15-second driver locks, conditional Postgres accepts, and O(1) SSE tracking.

  8. 08Design a Social Media News Feed (Twitter / X)

    Sub-100ms personalized feeds at 500K RPS: Kafka dual consumer groups, hybrid fan-out (push for normal users, O(1) Redis pull for celebrities), CDC celeb detection, and buffered viral likes.

  9. 09Design a Video Streaming Platform (YouTube / Netflix)

    1B DAU video streaming with 100:1 read/write ratio: 50 GB resumable S3 multipart uploads, Temporal parallel GOP transcoding, CDN adaptive bitrate playback, and Flink/ClickHouse engagement pipelines.

  10. 10Design Search Autocomplete (Typeahead)

    Sub-50ms top-5 suggestions at 200K keystrokes/sec: CDN edge caching for short prefixes, flattened O(1) Trie in Redis, Flink 1-minute streaming deltas, exponential time-decay, and dual-layer moderation.

  11. 11Design a Payment System & Ledger (Stripe)

    Exactly-once checkout and auditable double-entry accounting at 10K TPS: outbound PSP idempotency keys, Postgres WAL CDC transactional outbox, append-only net-zero ledger with O(1) balances, and two-tier reconciliation.

  12. 12Design an Enterprise LLM Gateway (Portkey)

    Sub-20ms OpenAI-compatible proxy at 5K RPS with 30–60s SSE streams: in-memory Vault/policy caches, token-aware Redis budgets, per-provider circuit-breaker fallbacks, and decoupled ClickHouse cost analytics.

  13. 13Design an Agent Sandbox Platform (E2B / Daytona)

    Sub-2s isolated code execution for 1,000+ concurrent AI agents: prewarmed Firecracker microVMs with CoW repo snapshots, host-side L7 Envoy egress & secret injection, S3 presigned artifacts, and dual-layer TTL reaping.

  14. 14Design OpsPilot (Human-in-the-Loop Runner)

    Durable AI incident & migration runner for 10,000+ concurrent parked workflows: Temporal Signal + 24h stale-approval guard, RBAC optimistic-locked approvals, idempotent K8s/Cloud steps, and Saga rollback.

esc
⌘B sidebar[ ] prev/next1–5 flowsc copyt theme