Tutorials System Design Mastery
The CAP Theorem: Consistency, Availability, or Partition Tolerance?
On this page
The CAP Theorem
In a distributed system, it is mathematically Impossible to simultaneously provide more than two out of the three following guarantees: Consistency, Availability, and Partition Tolerance.
1. The Three Pillars
- Consistency (C): Every read receives the most recent write or an error. (The system looks like a single node).
- Availability (A): Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
- Partition Tolerance (P): The system continues to operate despite an arbitrary number of messages being dropped or delayed by the network between nodes.
2. The Crucial Choice: CP vs AP
In a world where networks fail (P is mandatory), you must choose:
- CP (Consistency/Partition): If the network fails, stop responding to requests to ensure data stays valid. (e.g., Banking systems).
- AP (Availability/Partition): Keep responding to requests but allow nodes to have different versions of the data temporarily. (e.g., Facebook Likes or Youtube views).
4. Interview Mastery
Q: "Why is Partition Tolerance mandatory in the real world?"
Architect Answer: "Because the network is the most unreliable part of any system. Routers crash, cables are cut, and latency happens. If you build a system that is 'CA' (No Partition Tolerance), your entire system will crash the moment one network switch fails. Therefore, every modern distributed architecture is a trade-off between Consistency (CP) and Availability (AP) during a network partition."
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!