Logo
Published on

Strong vs Eventual Consistency - System Design Interview Mastery

βš”οΈ 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."