Use Cases
Find patterns by the kind of system you're building.
Web APIs & Microservices
Building a REST/gRPC service? These patterns keep it reliable under load.
| Scenario | Patterns | Real Example |
|---|---|---|
| Protect against downstream outages | Circuit Breaker + Retry with Backoff | Netflix Hystrix wraps every HTTP client call |
| API rate limiting | Rate Limiter | Stripe allows burst of 25, refills at 25/sec |
| Request middleware (auth, logging, tracing) | Middleware Chain | gRPC interceptors, Koa.js onion model |
| Service discovery | Registry | Consul, etcd service registration |
| Load distribution across nodes | Consistent Hashing | HAProxy, groupcache key distribution |
| Prevent overload | Backpressure + Batch Processing | Node.js stream piping, Kafka consumer groups |
Databases & Storage
The patterns behind PostgreSQL, Redis, LevelDB, and every serious storage engine.
| Scenario | Patterns | Real Example |
|---|---|---|
| Crash recovery | WAL + Checkpointing | PostgreSQL: WAL + periodic checkpoint |
| Write-heavy workload | LSM Tree + Bloom Filter | LevelDB/RocksDB: memtable → SSTable + bloom skip |
| Range queries on disk | B+ Tree | PostgreSQL btree index, SQLite |
| Concurrent reads/writes | MVCC | PostgreSQL tuple versioning, etcd revisions |
| Data integrity verification | Merkle Tree | ZFS block checksums, Git object store |
| Sorted key merge | Merge Iterator + Min Heap | LevelDB compaction |
| Delete without immediate removal | Tombstone | Cassandra tombstones, LevelDB deletion markers |
| In-memory sorted set | Skip List | Redis ZADD/ZRANGE sorted sets |
| In-memory cache | LRU Cache | Redis LRU eviction, Go groupcache |
| Event ordering without clocks | Logical Clock | etcd Raft log, DynamoDB version vectors |
Frontend & UI Frameworks
React, Vue, and browser engines use these patterns every frame.
| Scenario | Patterns | Real Example |
|---|---|---|
| Virtual DOM diffing | Diff / Patch + Bitmask | React reconciler: diff tree, apply minimal patches |
| Responsive rendering | Cooperative Scheduling | React Scheduler: yield every 5ms to stay under 16ms |
| Frame-safe state updates | Double Buffering | React Fiber: workInProgress ↔ current tree swap |
| Avoid unnecessary re-renders | Dirty Flag | React shouldComponentUpdate, Chromium layout |
| State management | Observer + State Machine | Redux subscribe, XState finite states |
| Priority-based task scheduling | Min Heap | React Scheduler priority queue |
Distributed Systems
Patterns for systems that span multiple machines.
| Scenario | Patterns | Real Example |
|---|---|---|
| Consensus log | WAL + Logical Clock | etcd Raft: append-only log with term/index |
| Partition-tolerant routing | Consistent Hashing | Amazon DynamoDB, Cassandra ring |
| Replicated state | State Machine + WAL | Raft: replicated state machine via log |
| Conflict-free replication | Logical Clock + Tombstone | CRDTs, Dynamo-style last-write-wins |
| Data synchronization | Merkle Tree | Cassandra anti-entropy repair |
| Message-driven architecture | Actor Model + Backpressure | Akka cluster, Erlang/OTP |
| Build/deploy pipelines | Dependency Graph + Batch Processing | Cargo build graph, pnpm workspace |
Runtime & Memory Management
How Go, CPython, V8, and game engines manage memory and execution.
| Scenario | Patterns | Real Example |
|---|---|---|
| Reduce GC pressure | Object Pool + Free List | Go sync.Pool, Linux SLUB allocator |
| Phase-based allocation | Arena Allocator | Rust bumpalo, Go arena (experimental) |
| Deterministic cleanup | Reference Counting | CPython refcount, Rust Rc/Arc |
| String deduplication | Interning + Flyweight | Rust compiler symbol interning, Python small int cache |
| Efficient cloning | Copy-on-Write | Linux fork(), Rust Cow<T> |
| Work distribution across cores | Work Stealing | Go runtime P/M/G scheduler, Tokio |
| I/O multiplexing | Event Loop + Ring Buffer | libuv (Node.js), Redis single-thread |
| Thread-safe counters | Semaphore | Linux kernel semaphores, Go x/sync |
Compilers & Language Tools
Patterns used in LLVM, V8, rustc, and the Vue/React compilers.
| Scenario | Patterns | Real Example |
|---|---|---|
| AST traversal | Visitor | LLVM InstVisitor, Vue compiler transforms |
| Dynamic dispatch | Vtable | CPython tp_* slots, Rust dyn Trait |
| Symbol tables | Interning + Trie | rustc Symbol interning |
| IR transformations | Iterator + Diff / Patch | Rust Iterator adapters, tree-sitter edits |
| Type representation | Tagged Union | V8 tagged pointers, PyTorch TensorImpl |
| Plugin systems | Registry + Middleware Chain | Babel plugins, webpack loaders |
Networking & Protocols
| Scenario | Patterns | Real Example |
|---|---|---|
| Connection state tracking | State Machine | Linux TCP state machine (SYN_SENT → ESTABLISHED → ...) |
| IP routing | Trie | Linux LC-trie for IPv4 FIB |
| Packet buffering | Ring Buffer | Linux sk_buff, DPDK ring |
| Flow control | Backpressure + Rate Limiter | TCP flow control, Nginx limit_req |
| DNS resolution | Trie + LRU Cache | Domain name lookup + response cache |