CAP Theorem
Definition
The CAP theorem, also known as Brewer's theorem, states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: Consistency, Availability, and Partition Tolerance.
Why It Matters
The CAP theorem is a fundamental principle in the design of distributed systems. It highlights the trade-offs that engineers must make. Because network partitions are a fact of life, you must choose between consistency and availability.
Contextual Example
In the event of a network partition (a failure in communication between servers), a system must choose: does it remain available but risk serving stale data (choosing Availability over Consistency), or does it refuse to respond to ensure no inconsistency occurs (choosing Consistency over Availability)?
Common Misunderstandings
- Consistency: Every read receives the most recent write or an error. Availability: Every request receives a (non-error) response. Partition Tolerance: The system continues to operate despite an arbitrary number of messages being dropped by the network between nodes.
- Traditional relational databases typically choose Consistency (CP), while many NoSQL databases are designed to choose Availability (AP).