System Design Patterns

Distributed system patterns — load balancing, caching, queues, replication, sharding.

Reference Reference Updated Apr 19, 2026
Reference

Scaling

Pattern What it does
Load balancer Distributes traffic across replicas (round-robin, least-conn, consistent-hash)
Horizontal scaling Add more machines
Vertical scaling Bigger machine
Sharding Partition data by key across shards
Replication Keep copies for read scale / failover
Read replicas Scale reads; writes go to primary
CDN Cache static assets geographically near users
Service mesh Sidecar proxies for routing, retries, mTLS

Caching

Pattern Notes
Cache-aside App reads cache first, falls back to DB
Write-through Write to cache and DB together
Write-behind Write to cache now, flush async to DB
Read-through Cache transparently fetches on miss
TTL / stale-while-revalidate Serve stale briefly while refreshing
Cache invalidation Hardest problem — prefer event-driven eviction

Async / messaging

Pattern Notes
Message queue Buffer producer/consumer; retry on failure
Pub/sub Fan-out to multiple subscribers
Event sourcing Store event log; replay to reconstruct state
CQRS Separate read model from write model
Saga Long-running multi-service transaction with compensations
Outbox pattern Atomically write to DB + outbox; relay publishes

Resilience

Pattern Notes
Circuit breaker Stop calling a failing dependency to let it recover
Bulkhead Isolate resources — one failure doesn't drown others
Timeout + retry + backoff Never retry without limits; use exponential backoff with jitter
Rate limiting Protect from overload (token bucket, leaky bucket)
Graceful degradation Serve reduced functionality when dependencies fail
Idempotency keys Allow safe retries without double-effects

Last updated: