All cheatsheets

Cheatsheets

System design

Scaling, caching, databases, load balancing, messaging, and estimation — with a reference diagram.

Visualize

Consistent hashing — the ring (3D)

Keys belong to the next node clockwise; adding a node remaps only ~1/N of the keys.

Loading 3D…

LRU cache

The least-recently-used entry is evicted when the cache is full.

access sequence
ABCADB
MRU → … → LRU
A

MISS — load A at the front.

26 entries

Scaling5

Vertical vs horizontal

Bigger box vs more boxes

Stateless services

Any instance serves any request → easy scale

Sharding / partitioning

Split data across nodes by key

Replication

Copies for read scaling & failover

Autoscaling

Add/remove capacity on demand

Caching5

CDN

Cache static assets at the edge

Cache-aside

App reads cache first; on miss, read DB and fill cache.

Write-through / behind

Write to cache then DB (sync/async)

TTL + invalidation

Hardest problem — expire & bust stale data

Redis / Memcached

In-memory key-value stores

Databases5

SQL vs NoSQL

Relational/ACID vs flexible/scale-out

CAP theorem

Under a network partition, pick consistency or availability.

Read replicas

Offload reads from the primary

Indexing

Speed reads; cost writes & storage

Connection pooling

Reuse DB connections under load

Traffic & messaging6

L4 vs L7 LB

Transport vs application-aware routing

Round robin / least-conn

Load balancing strategies

Queues / pub-sub

Decouple & smooth bursty work

Dead-letter queue

Park messages that keep failing

Backpressure

Slow producers when consumers lag

Idempotency

Safe retries — the same request applied twice has one effect.

Estimation & reliability5

Back-of-envelope

Recipe: size QPS, storage, and bandwidth before designing.

Latency numbers

Order-of-magnitude latencies every engineer should know.

p99 latency

Optimise tail, not just the average

SLA / SLO / SLI

Targets, objectives, indicators

Graceful degradation

Shed load, serve stale, keep the core path up.