Problem
Replicated data stores must keep working when links between nodes fail. Teams assume they can have perfect consistency and perfect availability simultaneously, then discover a partition forces a choice.
Also known as: brewers-theorem, cap
Reason about the unavoidable choice between consistency and availability when a network partition occurs in a replicated system.
Replicated data stores must keep working when links between nodes fail. Teams assume they can have perfect consistency and perfect availability simultaneously, then discover a partition forces a choice.
The CAP theorem, conjectured by Eric Brewer and proved by Gilbert and Lynch, states that a distributed data store cannot simultaneously guarantee linearizable consistency and availability of every request when the network is partitioned. Since partitions happen, the practical decision is what to give up while one is in progress.
Imagine two replicas that lose contact. A write arrives at one.
Client --write x=2--> [Replica A] ~~ partition ~~ [Replica B] (x=1)
CP choice: A rejects or blocks the write -> consistent, unavailable
AP choice: A accepts, B still serves x=1 -> available, inconsistent
CP systems typically require a quorum and refuse requests on the minority side. AP systems accept writes on both sides and reconcile later, using techniques such as last-write-wins, vector clocks, or CRDTs. Outside a partition, you can usually have both; the real costs show up as latency (see PACELC).
None: conceptual
Low: documenting behavior
Medium: subtle definitions
Assuming a system is CP or AP without reading its actual guarantees
Treating availability as uptime rather than every non-failing node responding
No reconciliation plan for AP writes after the partition heals