Trade-off Analysis
Every design decision has a cost-understanding trade-offs is what separates good from great.
1No Free Lunch
Trade-off analysis is the art of making and justifying engineering decisions when you can't have everything. Interviewers care less about what you choose and more about why you chose it.
2Classic Trade-offs
CAP theorem. Strong consistency requires coordination, reducing availability. Eventually consistent systems stay up longer.
Example: Banking: consistency. Social feeds: availability.
Batching improves throughput but adds latency. Streaming is low-latency but lower throughput.
Example: Real-time chat: latency. ETL pipelines: throughput.
Precompute and store results (use storage) or compute on demand (use compute).
Example: Materialized views vs live queries.
Simple systems are easier to maintain. Flexible systems handle more use cases but are complex.
Example: Monolith vs microservices.
More servers, faster databases, premium services cost money.
Example: Reserved instances vs on-demand.
3How to Present Trade-offs
4Database Trade-offs
| Choice | You Get | You Give Up |
|---|---|---|
| SQL | ACID, JOINs, mature tooling | Horizontal scaling, schema flexibility |
| NoSQL | Scalability, flexibility | JOINs, consistency guarantees |
| Indexing | Fast reads | Slower writes, more storage |
| Denormalization | Fast reads, no JOINs | Data duplication, update complexity |
| Sharding | Horizontal scale | Cross-shard queries, complexity |
5Architecture Trade-offs
| Choice | You Get | You Give Up |
|---|---|---|
| Microservices | Independent scaling, deployment | Network complexity, debugging difficulty |
| Monolith | Simplicity, easy debugging | Scaling flexibility, deployment coupling |
| Sync Processing | Simple, immediate response | Latency, coupling |
| Async Processing | Decoupling, resilience | Complexity, debugging, eventual consistency |
| Caching | Speed, reduced DB load | Stale data, cache invalidation complexity |
6Interview Phrases
Use These Phrases
7Key Takeaways
?Quiz
1. System needs strong consistency and high availability. What do you say?
2. You chose NoSQL. Interviewer asks about downsides. Best response?