Reference
System Design Cheatsheet
A quick reference for system design interviews and architecture decisions. Covers estimation, components, patterns, and trade-offs.
- Estimation â Back-of-the-envelope math
- Components â When to use what
- Patterns â Common design patterns
- Trade-offs â CAP, PACELC, and beyond
Keep this cheatsheet handy for interviews and architecture discussions.
Quick Estimation
Common Numbers
| Metric | Value |
|---|---|
| Seconds in a day | 86,400 |
| Seconds in a month | 2.6M |
| Seconds in a year | 31.5M |
| 1 million QPS | ~86B requests/day |
| Latency: memory | < 100ns |
| Latency: SSD | ~100us |
| Latency: HDD | ~10ms |
| Latency: Network (same DC) | ~500us |
| Latency: Network (cross-region) | ~50ms |
Database Selection
| Database | Use Case | Example |
|---|---|---|
| MySQL/PostgreSQL | ACID transactions, relational data | Orders, Users |
| MongoDB | Flexible schema, document storage | Content, Profiles |
| Cassandra | Write-heavy, time-series data | Metrics, Logs |
| Redis | Caching, sessions, leaderboards | Cache, Sessions |
| Elasticsearch | Full-text search, logging | Search, Logs |
| Neo4j | Graph relationships | Social graph |
| DynamoDB | Key-value, serverless | Session data |
Caching Patterns
| Pattern | Description | Trade-off |
|---|---|---|
| Cache-Aside | App manages cache | Flexible, extra hop |
| Write-Through | Write to cache + DB | Strong consistency, slow writes |
| Write-Behind | Write to cache, async to DB | Fast writes, data loss risk |
| Read-Through | Cache fetches from DB | Transparent, cache miss penalty |
Load Balancing Algorithms
| Algorithm | Description | Best For |
|---|---|---|
| Round Robin | Sequential distribution | Equal capacity servers |
| Weighted Round Robin | Proportional to weight | Mixed capacity |
| Least Connections | Fewest active connections | Long-lived connections |
| IP Hash | Hash of client IP | Sticky sessions |
| Consistent Hash | Hash ring | Distributed cache |
CAP Theorem
PACELC Theorem
Message Queue Comparison
| Queue | Throughput | Ordering | Persistence |
|---|---|---|---|
| Kafka | Very high | Partition-level | Disk |
| RabbitMQ | High | Queue-level | Disk/Memory |
| SQS | High | Best-effort | Disk |
| Pulsar | Very high | Partition-level | Disk |
Common Patterns
| Pattern | Problem | Solution |
|---|---|---|
| Circuit Breaker | Cascade failures | Short-circuit on failure |
| Retry | Transient failures | Exponential backoff + jitter |
| Saga | Distributed transactions | Compensating transactions |
| Outbox | Dual write problem | Transactional event publishing |
| Sidecar | Cross-cutting concerns | Co-located helper container |
| Strangler Fig | Monolith migration | Incremental replacement |
| Back Pressure | Overload | Flow control signaling |
Interview Tips
Practice Exercises
- Estimation: Estimate the QPS, storage, and bandwidth for a URL shortener with 100M URLs/month.
- Database: When would you choose Cassandra over PostgreSQL? Give specific use cases.
- Caching: Design a caching strategy for a social media feed with 1B daily reads.
- Patterns: Which patterns would you use for an e-commerce checkout flow?
What to Learn Next
-> System Design Interview Tips Ace your system design interview.
-> System Design Roadmap Learning path for system design.
-> CAP Theorem Consistency vs availability.
-> Load Balancing Distribution algorithms.
-> Caching Strategies Distributed caching.
-> Databases SQL vs NoSQL.