System Design Cheat Sheet: Architecture & Latency Guide
The essential high-density system design cheat sheet. Master latency numbers, back-of-the-envelope capacity estimations, database selection matrices, and the 4-step interview template.
1. Latency Numbers Every Programmer Should Know
Memorize orders of magnitude to justify architecture decisions (Memory vs Disk vs Network).
| Operation | Latency | Context & Takeaway |
|---|---|---|
| L1 Cache Reference | 0.5 ns | Fastest CPU hardware cache |
| Branch Mispredict | 5 ns | CPU pipeline stall |
| L2 Cache Reference | 7 ns | 14x slower than L1 |
| Mutex Lock / Unlock | 25 ns | Thread synchronization primitive |
| Main Memory (RAM) Access | 100 ns | 200x slower than L1 |
| Compress 1 KB with Snappy | 3,000 ns (3 µs) | Lightweight CPU compression |
| Send 1 KB over 1 Gbps Network | 10,000 ns (10 µs) | Local network packet transit |
| SSD Random Read | 150,000 ns (150 µs) | Flash memory access |
| Round Trip within Same Datacenter | 500,000 ns (0.5 ms) | Internal VPC microservice call |
| HDD Disk Seek | 10,000,000 ns (10 ms) | Spinning mechanical arm movement |
| Packet Roundtrip CA to Netherlands | 150,000,000 ns (150 ms) | Transatlantic fiber speed of light |
2. Back-of-the-Envelope Estimation Formulas
Mental shortcuts that demonstrate senior engineering instincts in under 2 minutes.
QPS = (DAU * reqs_per_day) / 100,000
Use 100,000 instead of 86,400 for rapid mental math. Peak QPS = Average QPS * 2 (or 3).
Storage = Write_QPS * 86,400 * Size
If Write QPS = 1,000 and payload = 1 KB: 1,000 * 86,400 * 1 KB ≈ 86.4 GB/day ≈ 31.5 TB/year.
RAM_Cache = 0.20 * Daily_Reads
20% of items generate 80% of reads. Keep that 20% in Redis cache cluster to achieve >95% hit rate.
| Power of 2 | Exact Bytes | Approximate Value | Symbol |
|---|---|---|---|
| 2^10 | 1,024 | 1 Thousand (1 KB) | Kilo |
| 2^20 | 1,048,576 | 1 Million (1 MB) | Mega |
| 2^30 | 1,073,741,824 | 1 Billion (1 GB) | Giga |
| 2^40 | 1,099,511,627,776 | 1 Trillion (1 TB) | Tera |
| 2^50 | 1,125,899,906,842,624 | 1 Quadrillion (1 PB) | Peta |
3. Database & Storage Selection Cheat Sheet
Choose the right data store by query pattern and consistency requirements.
Best For: Transactional ledgers, user accounts, e-commerce checkouts, relational JOINs.
Scaling Strategy: Vertical scaling → Read Replicas → PgBouncer connection pooling → Citus/Vitess sharding.
Best For: Massive write throughput, shopping carts, session states, IoT time-series.
Scaling Strategy: Partition key distributes across hash rings. LSM-tree append-only disk storage.
Best For: Leaderboards (Sorted Sets), rate limiters, session stores, hot cache-aside.
Eviction Policies: allkeys-lru (Least Recently Used), volatile-lru, volatile-ttl.
Best For: E-commerce product search, autocomplete, fuzzy matching, log analysis.
Data Structure: Inverted index mapping word tokens to document IDs.
4. The 4-Step System Design Interview Framework
How to pace your 45-minute interview without running out of time.
Agree on exactly 3 core functional user journeys. Agree on non-functional constraints: Availability (99.99%), Latency (p99 < 100ms), and Read:Write ratio.
Calculate QPS (Average & Peak), Network Bandwidth (ingress/egress), Daily Storage, 5-Year Storage Capacity, and Cache RAM sizing (80/20 rule).
Draw macro components: Client → CDN → Load Balancer → API Gateway → Stateless Microservices → Primary/Replica DB → Redis Cache → Kafka Queue.
Pick the hardest technical component: DB sharding keys, cache invalidation race conditions, data consistency (eventual consistency), rate limiting, and failure modes (circuit breakers).