- Published on
Strong vs Eventual Consistency - System Design Interview Mastery
Table of Contents
- βοΈ Strong vs Eventual Consistency (Interview Mastery)
- π· 1. Core Idea (1-liner clarity)
- π§ Script
- π‘ FAANG Q
- π· 2. Strong Consistency (Deep but crisp)
- β Key Points
- ποΈ Architecture Decision
- β οΈ Trade-offs
- π Signals (When to use)
- π§ Script
- π‘ FAANG Q
- π· 3. Eventual Consistency
- β Key Points
- ποΈ Architecture Decision
- β οΈ Trade-offs
- π Signals (When to use)
- π§ Script
- π‘ FAANG Q
- π· 4. Strong vs Eventual (Comparison Shortcut)
- π§ Script
- π· 5. Architecture Decision Framework (VERY IMPORTANT π₯)
- π― Ask these in interview:
- π§ Script
- π· 6. Real-World Mapping (Interviewer loves this)
- Strong Consistency
- Eventual Consistency
- π· 7. Hybrid Approach (Senior-level answer π)
- π₯ Best Answer Strategy
- π§ Script
- π‘ FAANG Q
- π· 8. Hidden Advanced Points (Add in interview π₯)
- π§ Script
- π· 9. One-line Closing (Perfect Ending)
βοΈ Strong vs Eventual Consistency (Interview Mastery)
π· 1. Core Idea (1-liner clarity)
- Strong Consistency β Always latest data (no stale reads)
- Eventual Consistency β Fast, but may return stale data temporarily
π§ Script
"Consistency defines whether all replicas return the same latest value. Strong gives correctness, eventual gives performance."
π‘ FAANG Q
Q: Why can't we always use strong consistency? A: Because of CAP theorem β during network partition, we must choose between Consistency vs Availability.
π· 2. Strong Consistency (Deep but crisp)
β Key Points
-
Guarantees latest write visibility
-
Uses synchronous replication
-
Writes succeed only after all/majority nodes updated
-
Often uses:
- Leader-based replication
- Quorum (W β₯ majority)
ποΈ Architecture Decision
-
Leader β handles all writes
-
Replicas β updated synchronously
-
Reads:
- From leader OR
- From replicas after sync
β οΈ Trade-offs
- β High latency (cross-region sync)
- β Lower availability (fails if nodes down)
- β No stale reads (strict correctness)
π Signals (When to use)
Use Strong Consistency when:
- Money involved π°
- Inventory critical
- No duplication allowed
- User expects instant correctness
π§ Script
"I'll use strong consistency for critical data like payments or inventory. I'll use synchronous replication and quorum to ensure all reads return the latest value."
π‘ FAANG Q
Q: How do you implement strong consistency globally? A:
- Leader-based replication
- Synchronous writes
- Quorum (W + R > N)
- Example: Google Spanner uses TrueTime for global consistency
π· 3. Eventual Consistency
β Key Points
- Data becomes consistent over time
- Uses asynchronous replication
- Writes succeed immediately
- Temporary stale reads possible
ποΈ Architecture Decision
-
Multi-leader OR leaderless (Dynamo-style)
-
Background replication
-
Conflict resolution:
- Last write wins
- Vector clocks
β οΈ Trade-offs
- β Very fast (low latency)
- β Highly available
- β Temporary inconsistency
π Signals (When to use)
Use Eventual Consistency when:
- High traffic systems
- Global users π
- Slight delay acceptable
- Reads >> Writes
π§ Script
"I'll use eventual consistency where latency and availability matter more than perfect accuracy, using async replication and conflict resolution."
π‘ FAANG Q
Q: How do you handle conflicts in eventual consistency? A:
- Last-write-wins
- Versioning (vector clocks)
- Application-level merge
π· 4. Strong vs Eventual (Comparison Shortcut)
| Factor | Strong | Eventual |
|---|---|---|
| Data | Always latest | Might be stale |
| Latency | High | Low |
| Availability | Lower | High |
| Replication | Sync | Async |
| Use case | Banking | Social media |
π§ Script
"Strong consistency sacrifices availability and latency for correctness, while eventual consistency sacrifices correctness temporarily for performance and availability."
π· 5. Architecture Decision Framework (VERY IMPORTANT π₯)
π― Ask these in interview:
1. Can system tolerate stale data?
- β NO β Strong
- β YES β Eventual
2. Is system global?
- β YES β Eventual preferred
3. Is data critical?
- β YES β Strong
4. Read-heavy system?
- β YES β Eventual
5. Partition tolerance needed?
- β YES β Eventual
π§ Script
"I'll decide based on business needs: if correctness is critical I'll choose strong, otherwise I'll optimize for availability using eventual consistency."
π· 6. Real-World Mapping (Interviewer loves this)
Strong Consistency
- Banking systems
- Payment processing
- Booking systems
Eventual Consistency
- Social feeds
- Chat systems
- CDN caching
- Analytics
Examples:
- Amazon DynamoDB β eventual (default)
- Apache Cassandra β eventual
π· 7. Hybrid Approach (Senior-level answer π)
π₯ Best Answer Strategy
Use BOTH:
| Component | Consistency |
|---|---|
| Payments | Strong |
| Inventory | Strong |
| Recommendations | Eventual |
| Likes/Views | Eventual |
π§ Script
"In real systems, I use hybrid consistencyβstrong for critical paths and eventual for derived or high-scale components."
π‘ FAANG Q
Q: How would you design an e-commerce system consistency? A:
- Payments β Strong
- Inventory β Strong
- Recommendations β Eventual
- Analytics β Eventual
π· 8. Hidden Advanced Points (Add in interview π₯)
-
CAP Theorem:
- Strong β CP
- Eventual β AP
-
Quorum tuning:
- Strong: W + R > N
- Eventual: W = 1, R = 1
-
Read-your-writes consistency (middle ground)
π§ Script
"This is a CAP trade-off: strong consistency favors consistency over availability, while eventual consistency favors availability and partition tolerance."
π· 9. One-line Closing (Perfect Ending)
"There is no one-size-fits-allβstrong consistency for correctness-critical paths, eventual consistency for scalable and highly available systems."