liveBook · Manning

CAP theorem

As explained in The Coder Cafe

The CAP theorem states that a distributed system cannot simultaneously guarantee strong consistency, availability, and partition tolerance when a network partition occurs.

The CAP theorem describes a fundamental distributed-systems trade-off: when a network partition occurs, a data store must choose between consistency and availability. Partition tolerance is essential because network instability is inevitable. section 6.2 section 6.0

The three CAP properties mean:

  • Consistency means every read returns the most recent write or an error; here, consistency specifically means linearizability. section 6.2
  • Availability means every request receives a non-error response, even when the response may contain outdated data. section 6.2
  • Partition tolerance means continuing to operate correctly when communication between nodes is lost or delayed. section 6.2

During a partition, systems commonly make one of these choices:

  • CP preserves the most recent value but may reject or fail requests during the partition. section 6.2
  • AP continues responding during the partition but may return stale data. section 6.2
  • CA can provide consistency and availability only when partitions are absent; it is not viable when network instability must be tolerated. section 6.2

A network partition

Suppose communication between database nodes is dropped or delayed. A CP design refuses some requests to avoid serving stale data; an AP design keeps serving requests while accepting that replicas may disagree temporarily. section 6.2

Use the figure to compare consistency, availability, and partition tolerance and to locate the CP, AP, and CA trade-offs. section 6.2

How The Coder Cafe covers it

How deep it goes
Defines all three properties and contrasts CP, AP, and CA, without developing implementation algorithms or operational procedures.
Examples
Uses dropped or delayed node communication to contrast stale responses with failed requests during a partition.
What it assumes
Builds on distributed databases and contrasts with ACID guarantees provided within a single node or tightly coupled cluster.
What you can do after
Evaluate database designs and vendor choices by identifying their consistency, availability, and partition-tolerance trade-offs.
How it connects
Connects CAP with ACID, PACELC, consistency models, consensus, and availability models.

Also explained in

Compare how 7 books explain CAP theorem →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.