#17 15 pages
System Design
Core patterns for designing scalable, reliable distributed systems. Covers the building blocks you need for both production engineering and system design interviews.
Files
| File | Topics | Level |
|---|---|---|
| scaling.md | 3-tier architecture, vertical vs horizontal, DB read replicas, sharding, resharding, consistent hashing, celebrity problem, fan-out, circuit breaker, backpressure | SDE-1/2 |
| cap-pacelc.md | CAP theorem, CP vs AP, consistency models (linearizable→eventual), PACELC, quorum math, vector clocks, tunable consistency | SDE-2 |
| rate-limiting.md | Fixed window, sliding window, token bucket, leaky bucket, Redis Lua implementation, distributed rate limiting, nginx, AWS API GW | SDE-1/2 |
| async-patterns.md | Message queues, pub/sub, DLQ, Saga (choreography/orchestration), outbox pattern, CQRS, event sourcing, idempotency, backpressure | SDE-2 |
| api-design.md | REST vs GraphQL vs gRPC, versioning, pagination (cursor/keyset), idempotency keys, API gateway, auth patterns, webhooks, OpenAPI | SDE-1/2 |
| distributed-transactions.md | Dual-write problem, 2PC, Saga, outbox pattern, CDC/Debezium, distributed locking (Redlock), optimistic concurrency, TCC, Spanner/TrueTime commit-wait | SDE-2 |
| file-transfer-storage.md | Presigned URLs, multipart/resumable upload (tus), chunking + content-addressable dedup, replication vs erasure coding, metadata service design, CDN delivery | SDE-2 |
| realtime-chat.md | WebSocket/long-polling/SSE, connection registry + cross-server relay, delivery guarantees, presence, multi-device fan-out, MQTT, WebRTC calling | SDE-2 |
| end-to-end-encryption.md | Signal Protocol (X3DH, Double Ratchet), hybrid symmetric/asymmetric model, Sender Keys for group chat, multi-device encryption, encrypted backups, server-visibility architecture | SDE-2 |
| distributed-id-generation.md | UUID v4 vs ULID/UUIDv7, Twitter Snowflake bit layout, clock-drift handling, ticket servers, range/segment allocation | SDE-2 |
| geospatial-services.md | Geohashing, quadtrees, S2 geometry, Redis GEO commands, ride-hailing matching, KNN vs radius search | SDE-2 |
| probabilistic-data-structures.md | Bloom filter recap, HyperLogLog cardinality estimation (live simulator), Count-Min Sketch frequency estimation | SDE-2 |
| search-system.md | Inverted index, BM25 scoring, ES cluster design for 1B docs, ILM, zero-downtime reindex, autocomplete strategies, relevance tuning, k-NN vector search | SDE-2/Staff |
| notification-system.md | FCM/APNs integration, fan-out strategies, device token registry, delivery receipts, batching/throttling, DND hours | SDE-2 |
| observability-system.md | Metrics/logs/traces pipeline design, cardinality, alerting system, multi-tenant Mimir/Loki, failure modes | SDE-2/Staff |
Read order: scaling → cap-pacelc → rate-limiting → async-patterns → api-design → distributed-transactions → file-transfer-storage → realtime-chat → end-to-end-encryption → distributed-id-generation → geospatial-services → probabilistic-data-structures → search-system → notification-system → observability-system
Mental Model
User Request
│
▼
CDN / Edge Cache ──── (static assets, public API responses)
│ miss
▼
Load Balancer (L7)
│
▼
Stateless App Servers ──── Rate Limiter ──── Auth (JWT/OAuth2)
│
├──► Cache (Redis) ──── cache-aside, TTL, eviction
│
├──► Database (primary) ──── write path
│ └── Read Replicas ──── read scaling
│ └── Shards ──── write scaling
│
├──► Message Queue ──── async jobs, fan-out, retry
│ └── Workers
│
└──► External APIs ──── circuit breaker, timeout, retry
When to Apply Each Pattern
| Symptom | Pattern |
|---|---|
| App servers are CPU-bound | Horizontal scale + LB |
| DB reads are slow | Read replicas + Redis cache |
| DB writes are slow | Vertical scale → sharding |
| Single key getting hammered | Celebrity problem → key splitting / L1 cache |
| Slow synchronous operations (email, resize) | Async queue + workers |
| Downstream service is flaky | Circuit breaker + exponential backoff |
| Need distributed transaction | Saga + outbox pattern (avoid 2PC) |
| Need to prevent duplicate processing | Idempotency keys + dedup table |
| API is getting hammered | Rate limiting (token bucket) |
| Strong consistency required | CP system + quorum reads |
| High availability over consistency | AP system + eventual consistency |
Pages in this section
System Design: 3-Tier Architecture & Scaling
From a single server to a globally distributed system. Every scaling decision has a cost — this guide explains the tradeoffs, not just the patterns.
CAP Theorem, PACELC, and Distributed System Tradeoffs
A field guide to the tradeoffs every distributed system makes — during a network partition, and even when nothing is broken. What you give up, when, and why the
Rate Limiting
Algorithms, distributed implementations, and production patterns.
Async Patterns — Message Queues and Event-Driven Architecture
How services hand off work without blocking on each other — queue patterns, delivery guarantees, dead letter queues, the outbox and saga patterns for keeping da
API Design
Production-focused reference for REST, versioning, pagination, idempotency, and API gateways.
Distributed Transactions
Patterns for maintaining consistency across services and datastores without a global ACID transaction.
File Transfer & Storage at Scale
How large files actually move between a client and durable storage — presigned URLs, multipart and resumable upload protocols, integrity verification, content-a
Real-Time Chat & Messaging Systems
Why request/response breaks down for chat, the transport options that fix it, and everything that gets hard once you scale past one server: connection registrie
End-to-End Encryption — Signal Protocol and System Design
How a messaging app like WhatsApp or Signal keeps a server from ever reading a message, using
Distributed ID Generation
Every row, event, and message needs a unique identifier — and the moment you have more than one process minting them, "just increment a number" stops being a sa
Geospatial & Location-Based Services
Every "near me" feature — restaurants nearby, drivers within 3km, friends on a map — boils down to the same question: given a point, which of millions of other
Probabilistic Data Structures — Trading Certainty for Space
Every structure in this file answers a question exactly wrong, on purpose. A hash set gives you exact set membership by storing every element; a hash map gives
Search System Design
An inverted index maps every term to the list of documents containing it — the core idea is the same whether you are searching 10,000 records or 10 billion. Thi
Notification System Design
A notification system decouples the act of generating an event from the act of telling someone about it — it handles fan-out to millions of devices across chann
Observability System Design
Designing an observability platform means building three interconnected pipelines — metrics, logs, and traces — that converge into a unified query and alerting