Consistency, CAP & trade-offs
During a network partition, choose whether consistency or availability matters more.
Visual model
A partition forces a product choice
The CAP theorem, honestly
CAP describes a network partition. The system must choose consistency or availability until the nodes can communicate again.
Consistency means every read sees the latest write. Availability means every request still gets a response.
Partitions happen. The real choice is CP, which may refuse requests to stay correct, or AP, which stays up and reconciles later.
PACELC adds the healthy case. Even without a partition, stronger consistency usually costs extra coordination and latency.
Strong vs eventual consistency
Strong consistency means every read reflects the latest write. Use it for money, inventory and uniqueness constraints. It costs coordination and latency.
Eventual consistency lets replicas converge over time, so a read may be briefly stale.
It fits feeds, likes and view counts, where low latency matters more than seeing the latest value immediately.
See it
Choose consistency per feature
Key takeaways
- Partitions are unavoidable. Decide per feature whether to stay correct (CP) or stay up (AP).
- Use strong consistency for money and uniqueness. Use eventual consistency for feeds and counts.
- Even without partitions, stronger consistency costs latency. Do not pay for it when you do not need it.