The CAP Theorem, proposed by Eric Brewer in 2000 and formally proven by Seth Gilbert and Nancy Lynch in 2002, states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees:
Every read receives the most recent write or an error. All nodes in the distributed system see the exact same data at the same time.
Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.
In a real-world distributed system, network partitions will happen. Cables get cut by construction workers, switches fail, and data centers lose connectivity. Therefore, Partition Tolerance (P) is not optional—it is a requirement. You must choose P.
This forces you to choose between Consistency and Availability:
When a network partition occurs, the system will refuse to respond (sacrificing Availability) rather than risk returning stale data (maintaining Consistency).
When a network partition occurs, the system will return whatever data it has (sacrificing Consistency) rather than going offline (maintaining Availability).
The CAP theorem only describes behavior during network partitions. In 2012, Daniel Abadi proposed the PACELC theorem, which extends CAP:
If there is a Partition, how does the system trade off Availability and Consistency? Else (when the system is running normally, without partitions), how does the system trade off Latency and Consistency?
This is important because even when the network is perfectly healthy, the system must decide: Should a write operation wait for all replicas to confirm (high consistency, high latency)? Or should it return immediately after one replica confirms (low latency, risk of inconsistency)?