Bookmarks

CAP theorem

A statement from the theory of distributed systems: when the network is partitioned, a data store sacrifices consistency or availability.

Also: CAP principle, Brewer’s conjecture, Brewer’s theorem

checked 18 Nov

All terms

A distributed data store promises three things at once: every node answers any request (availability), all clients see the same data (consistency), and the system keeps working even when the network is partitioned (partition tolerance). The CAP theorem states that no system delivers all three promises at once: when a partition happens, a data store sacrifices consistency or availability.

What C, A and P mean

PropertyWhat it promisesWhat happens during a network partition
C — consistencyevery read returns the latest written record or an errorthe node replies with an error if it is not sure its data is up to date
A — availabilityevery request receives a response, even if not the freshest onethe node keeps answering from its own local data
P — partition tolerancethe system keeps working even when the link between nodes is brokenthe network between nodes no longer delivers messages

How the choice is made

When the network is partitioned, a system either rejects writes and reads of stale data or keeps answering with out-of-date copies. CP systems preserve consistency and lose availability: etcd by default routes every read through cluster consensus and does not respond without a quorum of nodes. AP systems stay available and diverge: at a low consistency level, Cassandra serves data from the nearest replica, and the copies converge once the network recovers.

  • CP — etcd, ZooKeeper, PostgreSQL with synchronous replication: a write succeeds only if a quorum of nodes or a synchronous standby acknowledges it;
  • AP — DNS, web caches, Cassandra at a low consistency level: a node answers from its local data, and diverging copies converge later.

Where the theorem comes from

In 2000, Eric Brewer set out this line of reasoning as a conjecture in an invited talk at the PODC conference, and in 2002 Seth Gilbert and Nancy Lynch proved it for an asynchronous network model with atomic (linearizable) data. Brewer emphasised that the choice is not a switch but a spectrum: practical systems remain a mix of strict (ACID) and available but weakly consistent (BASE) subsystems.

Sources

the term is written from these pages

Verified 18 Nov

Not to be confused with

what it is mixed up with and how it differs

  • PACELC theorem

    PACELC extends CAP with the partition-free case: even then, the choice remains between latency and consistency.

  • ACIDACID transaction properties

    ACID — transaction guarantees within a single DBMS; the C in ACID stands for data integrity, not CAP consistency between replicas.

  • eventual consistency

    Eventual consistency — the model AP systems choose when they sacrifice the strict consistency of CAP.