skip to content
jaeaeichsysdes

cheat sheet

Quick-scan numbers, prompt-to-pattern mappings, and every topic's one-line rule of thumb. Press ⌘K anytime to jump straight to a deep dive.

01 · numbers to know cold

Latency Ladder

L1 / RAM
1 ns · 100 ns
Redis (in-VPC)
~0.5 ms
SSD random read
~0.1 ms
Cross-AZ / DB query
1–10 ms
Cross-region RTT
50–150 ms

Single-Box Caps

App server
1K–10K RPS
Postgres
~10K QPS · 64 TB
Redis
~100K ops/s · RAM
Kafka broker
~1M msg/s · GB/s
S3 / Object
∞ storage · high BW

Fast Math Shortcuts

1 day
≈ 10⁵ sec (86,400)
Daily → avg RPS
chop 5 zeros
Peak RPS
2–3× avg (10× flash)
Bloom 1% FP
~10 bits / key
Quorum
W + R > N (2F+1)

02 · when the prompt says x → reach for y

Short URL / 100:1 read-heavy redirectsSnowflake Base62 + Redis LRU + CDC Bloom filter guardGlobal API rate limiting at 1M RPSEdge Envoy sidecar + sharded Redis Lua sliding-window counterScheduled / cron jobs at scaleTime-bucketed DB (`FOR UPDATE SKIP LOCKED`) + Kafka + idempotent K8s workersMetrics ingestion & sub-second p99 alertsBatched gzip → Kafka → ClickHouse rollups + Flink DDSketch + fixed-TTL dedup1:1 / group real-time chat + offline pushL4 stateful WebSockets + Redis user→ws map + 1 queue/WS + Snowflake orderingFlash-sale ticketing / zero double-bookingEdge waiting room + 6.25 KB Redis bitmap 10m hold + Stripe webhook PG commitNearby drivers & live trip dispatchRedis GEO (4s GPS) + 30s driver lock lease + sequential dispatch + WS streamSocial feed (<100ms reads + celebrities)Hybrid fan-out (push normal, pull celebs) + dual Redis shards (IDs + bodies)50 GB video upload & global ABR playbackPre-signed S3 multipart + Kafka DAG FFmpeg workers + HLS/DASH on CDNSub-50ms search typeahead + breaking trends50ms debounce + CDN (1–2 chars) + flattened Redis Trie + Flink time-decay + S3 snapshotPayments & auditable double-entry ledgerOutbound `idempotency_key=order_id` + WAL CDC + net-zero ACID PG + 2-tier reconEnterprise LLM proxy, SSE streaming & token budgetsIn-mem Vault/policy cache + Redis TPM limits + per-provider CB fallback + Kafka→ClickHouseIsolated AI agent code sandboxes (<2s startup)Prewarmed Firecracker microVMs + CoW snapshots + host Envoy secret injection + dual TTL reaperHuman-in-the-loop incident & migration runnerTemporal Signal + 24h stale timer + PG optimistic approval lock + idempotent Saga rollback

03 · all 29 rules of thumb

case studies

Design a URL Shortenerwrite path · read path · core trade-off

Never trust an async Bloom filter alone for uniqueness — use DynamoDB's conditional put (attribute_not_exists) as the true guard.

Design a Distributed Rate Limiterplacement · control vs data · algorithm & failure

Shard Redis counters by rule_id:entity_id (never rule_id alone) so a single high-traffic global rule never melts one shard.

Design a Distributed Job Schedulerstorage & sharding · dispatch without drift · execution & retries

Never dual-write Postgres and RabbitMQ — commit the job row in Postgres first and stream it via CDC/outbox, then enforce optimistic locking on status transitions.

Design a Metrics & Alerting Systemwrite-heavy ingest · fast dashboards · real-time alerts

Never refresh an alert's dedup TTL on every firing tick — you will silence a 6-hour outage forever. Use explicit state transitions (FIRING → RESOLVED) plus fixed-TTL cooldowns.

Design a Real-Time Chat Systemstateful delivery · storage & ordering · media & presence

Key the WebSocket routing table by user_id (holding a map of active devices), never by group_id:user_id — otherwise every reconnect rewrites dozens of group keys and breaks multi-device.

Design Ticketmaster (Event Booking)dual consistency · 6.25 KB seat map · DB truth + refund

Never trust a Redis SETNX lock alone for financial seat ownership — enforce final uniqueness with a conditional DB write and wire an automated Refund path for late payments.

Design Ride-Hailing (Uber / Lyft)geo index & liveness · sequential 15s lock · zero TOCTOU + tracking

Scope the lock key strictly to the contested resource (driver:{id}:lock) with ride_id as the VALUE — never put ride_id in the key, or two rides can lock the same driver simultaneously.

Design a Social Media News Feed (Twitter / X)hybrid fan-out · dual Redis shards · viral writes

Pure push stalls on 50M-follower celebrities; pure pull is too slow when you follow 1,000 normal accounts. Hybrid fan-out gives O(1) reads without celebrity write amplification.

Design a Video Streaming Platform (YouTube / Netflix)resumable 50 GB upload · DAG transcoding · ABR playback & counts

Never generate unique per-user presigned URLs for every 4-second video chunk — unique query strings destroy CDN cache hit rates. Use static CDN URLs (or CDN Signed Cookies for paid/private streams).

Design Search Autocomplete (Typeahead)O(1) flattened Trie · time-decay trends · dual-layer bans

Never traverse a distributed Trie over the network per keystroke, and never rebuild the Trie from Redis — Redis only holds top-5 per prefix, so keep the full long-tail snapshot in S3.

Design a Payment System & Ledger (Stripe)two-layer idempotency · CDC outbox, no dual-write · append-only net-zero ledger

In financial systems, never DELETE or overwrite ledger rows, never rely on webhooks alone without a reconciliation poller, and never trust an eventually consistent OLAP store as your source of truth.

Design an Enterprise LLM Gateway (Portkey)keep Vault & DB off the hot path · token-aware budgets + CB fallback · decouple billing & traces

Never put Vault, Postgres, or ClickHouse synchronously on the LLM hot path — cache keys and policies in RAM, rate-limit by tokens rather than RPS, and emit billing events only after the stream closes.

Design an Agent Sandbox Platform (E2B / Daytona)microVMs + CoW snapshots · host-side L7 egress & secrets · disposable VMs + dual reaper

Treat every agent sandbox as hostile and disposable — never share the host kernel, never write raw secrets to VM disk, and let an external orchestrator (Temporal) own retry state.

Design OpsPilot (Human-in-the-Loop Runner)Temporal replaces custom state machines · consistency >> availability on approvals · idempotent steps + Saga rollback

Never execute production mutations directly from a Slack webhook or hold worker threads open waiting for humans — park in Temporal on a Signal + TTL timer, lock approval in Postgres, and compensate via Saga on failure.

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