Cheat Sheet

Quick reference for system design interviews. Everything you need at a glance.

·
1M req/day≈ 12 QPS
1B req/day≈ 12,000 QPS
Seconds in a day86,400 (round to ~100K)
RAM access100 ns
SSD random read150 μs
HDD seek10 ms
Same-DC round trip500 μs
Cross-continent150 ms
1 char1 byte (ASCII) / 2 bytes (Unicode)
1M rows × 1KB= 1 GB
1B rows × 1KB= 1 TB
2^10≈ 1 Thousand (1 KB)
2^20≈ 1 Million (1 MB)
2^30≈ 1 Billion (1 GB)
2^40≈ 1 Trillion (1 TB)
Step 1 (5 min)Clarify requirements - ask questions, define scope, functional & non-functional requirements
Step 2 (5 min)Back-of-envelope - calculate QPS, storage, bandwidth, peak traffic
Step 3 (10 min)High-level design - draw core components, define APIs, data flow
Step 4 (15 min)Deep dive - detail 2-3 interesting components, discuss algorithms
Step 5 (10 min)Scaling & trade-offs - bottlenecks, failure handling, monitoring
SQL (PostgreSQL, MySQL)Structured data, ACID, complex queries, joins, reporting. Good for: user accounts, orders, financial data
Document DB (MongoDB)Flexible schema, JSON-like, good for: product catalogs, user profiles, content management
Key-Value (Redis, DynamoDB)Simple get/put, highest throughput. Good for: caching, sessions, leaderboards, rate limiting
Wide-Column (Cassandra, HBase)Write-optimized, massive scale. Good for: time-series, messaging, activity logs, IoT
Graph (Neo4j)Relationship traversal. Good for: social networks, recommendation engines, fraud detection
Search (Elasticsearch)Full-text search, inverted index. Good for: product search, log analysis, autocomplete
Time-Series (InfluxDB)Optimized for time-stamped data. Good for: metrics, monitoring, IoT sensor data
Cache-AsideApp checks cache → miss → read DB → write cache. Most common. Good for: read-heavy workloads
Write-ThroughWrite to cache + DB simultaneously. Consistent but slower writes. Good for: data you always read after write
Write-BehindWrite to cache, async to DB. Fastest writes but risk of data loss. Good for: write-heavy, loss-tolerant
LRU EvictionRemove least recently used. Best general-purpose policy. Default choice
TTL-basedKeys expire after time. Combine with LRU. Set based on data freshness needs
Round RobinEqual distribution. Simple. Default choice
Weighted Round RobinMore traffic to stronger servers
Least ConnectionsRoute to server with fewest active connections
IP HashSame client → same server. Session stickiness
Consistent HashingMinimize redistribution on server changes. Used by CDNs
KafkaDistributed log, high throughput (millions/sec), ordered per partition, replay. Best for: event streaming, data pipelines
RabbitMQTraditional broker, flexible routing, lower latency. Best for: task queues, RPC, complex routing
SQSAWS managed, simple, auto-scaling. Best for: serverless, simple async processing
Redis StreamsLightweight, built into Redis. Best for: simple pub/sub when you already have Redis
CP SystemsMongoDB, HBase, Zookeeper - sacrifice availability during partitions. Use when: consistency is critical (financial)
AP SystemsCassandra, DynamoDB, CouchDB - sacrifice consistency during partitions. Use when: availability is critical (social media)
TunableDynamoDB, Cassandra - choose per-request. W+R>N = strong consistency. W=1,R=1 = eventual consistency
Rate LimitingToken Bucket (allows bursts), Sliding Window (precise), Fixed Window (simple). Use Redis + Lua for distributed
IdempotencySame request → same result. Use unique idempotency keys. Critical for payments, message delivery
Circuit BreakerStop calling failing service. States: Closed → Open → Half-Open. Prevents cascading failures
CQRSSeparate read/write models. Write to normalized DB, read from denormalized view. Good for read-heavy systems
Saga PatternDistributed transactions via local transactions + compensating actions. Choreography (events) or Orchestration (coordinator)
Fan-outOn write: pre-compute (fast reads). On read: compute on demand (fast writes). Hybrid for celebrity problem
Consistent HashingHash ring with virtual nodes. K/N keys move on node change. Used in: caches, DB sharding, CDNs
Bloom FilterProbabilistic set membership. 'Definitely not' or 'probably yes'. 10 bits/element for 1% FP rate
200 OKSuccess
201 CreatedResource created (POST)
301 Moved PermanentlyPermanent redirect (browser caches)
302 FoundTemporary redirect (browser asks again)
400 Bad RequestInvalid input
401 UnauthorizedNot authenticated
403 ForbiddenAuthenticated but not authorized
404 Not FoundResource doesn't exist
429 Too Many RequestsRate limited
500 Internal Server ErrorServer bug
503 Service UnavailableServer overloaded or maintenance
Stateless serversNo session data on servers → easy horizontal scaling behind LB
Database read replicasOffload reads to replicas, write to primary
Database shardingSplit data across DBs when single DB can't handle load
Caching layerRedis/Memcached for hot data. 80/20 rule. Sub-ms latency
CDNEdge cache for static assets and API responses. Reduce origin load
Message queuesDecouple services, absorb spikes, async processing
Connection poolingReuse DB/cache connections instead of creating new ones
Auto-scalingScale servers based on CPU/memory/queue depth metrics