Chapter 19: CAP Theorem and Consistency Models in Practice

You covered CAP in the DB guide. Here's the practical system design perspective:

In Practice: It's About Latency

The real trade-off isn't "pick 2 of 3." It's: during a network partition, do you return stale data (AP) or an error (CP)?

Consistency Spectrum

Strong ◄────────────────────────────────────────► Eventual (always latest) (converges over time) Banking Shopping Cart Social Feed DNS (must be exact) (last-write-wins OK) (stale OK) (hours stale OK)

Practical Patterns

System Design Implications

ChoiceArchitectureExample
Strong consistencySingle leader, synchronous replicationBank account balance
Eventual consistencyMulti-leader/leaderless, async replicationSocial media likes count
MixedStrong for critical paths, eventual for othersMost real systems
💡 Practical Rule

Use strong consistency for money/inventory/auth. Use eventual consistency for feeds/counters/analytics. Most systems are a mix.