System Design Cheat Sheet 【4K — HD】

Stale data, thundering herd, cache stampede. 5. Asynchronous Processing Patterns | Pattern | Description | Use case | |---------|-------------|----------| | Message queue | Producer → queue → consumer | Task distribution, load smoothing | | Pub/Sub | One-to-many fanout | Event-driven updates, notifications | | Event sourcing | Store state as event log | Audit, replay, CQRS | | CQRS | Separate read/write models | Complex domains, high read/write asymmetry | | Saga | Distributed transaction via compensating events | Cross-service consistency |

Pick 2 of (C, A, P) — in practice, AP (eventual consistency) or CP (strong consistency with possible downtime). 3. Database Selection Guide | Workload | Recommendation | Rationale | |----------|---------------|-----------| | Strong ACID, complex joins | PostgreSQL, MySQL (RDBMS) | Transactions, referential integrity | | High write throughput, simple lookups | Cassandra, DynamoDB | Partitioned wide-column | | Flexible schema, rapid iteration | MongoDB, Couchbase | Document store | | Search | Elasticsearch | Inverted indexes, full-text | | Real-time analytics | ClickHouse, Druid | Columnar storage | | Graph relationships | Neo4j, ArangoDB | Graph traversal | system design cheat sheet

Ordering, at-least-once vs exactly-once, dead-letter queues, backpressure. 6. Consistency & Replication | Model | Behavior | Latency | Data loss risk | |-------|----------|---------|----------------| | Strong | All reads see latest write | Higher | None (if quorum) | | Eventual | Reads may be stale, converge over time | Lower | Possible during failover | | Read-your-writes | Session sees own writes | Medium | None | | Monotonic reads | Reads never go back in time | Medium | None | Stale data, thundering herd, cache stampede

LRU, LFU, TTL, FIFO.