Back to Blog
June 9, 20261,000 views

CAP Theorem Explained: Consistency, Availability & Partition Tolerance (Visualized)

The CAP theorem states that a distributed data store can provide at most two of three guarantees β€” Consistency, Availability, and Partition tolerance β€” at the same time. Because network partitions are unavoidable, the real choice is consistency versus availability. Here's what that means, with live animations.

The CAP theorem (also called Brewer's theorem) states that a distributed data store can simultaneously guarantee at most two of these three properties: Consistency, Availability, and Partition tolerance. It is one of the most cited β€” and most misunderstood β€” ideas in distributed systems.

The Three Guarantees

Consistency (C): every read receives the most recent write or an error. All nodes see the same data at the same time. Availability (A): every request receives a non-error response, without the guarantee that it contains the latest write. Partition tolerance (P): the system keeps operating even when the network drops or delays messages between nodes.

CAP: pick two
The two highlighted properties are the ones a system keeps. The third is sacrificed.

Why It's Really 'Pick C or A'

Here is the part most explanations skip: in any real distributed system, network partitions will happen β€” cables fail, switches reboot, packets drop. So partition tolerance is not optional; you must design for it. That collapses the famous "pick two" into a single practical choice: when a partition occurs, do you favor consistency or availability?

A CP system refuses to answer (or rejects writes) on the side of the partition that can't confirm it has the latest data β€” staying consistent at the cost of availability. An AP system keeps answering on both sides, possibly with stale data, and reconciles later. Watch both behaviors on the same partition:

CP vs AP during a network partition
A write hits Node A, then the network partitions. CP mode returns an error on Node B to stay consistent; AP mode serves stale data to stay available, then reconciles when the partition heals.

CP, AP, and the Myth of CA

ChoiceBehavior during a partitionExample systems
CPReject reads/writes to stay consistentetcd, ZooKeeper, HBase, MongoDB (default)
APStay available, reconcile later (eventual consistency)Cassandra, DynamoDB, Riak, CouchDB
CAOnly possible with no partition β€” i.e. a single nodeA single-node SQL database

"CA" is effectively a myth for distributed systems: the moment you have more than one node communicating over a network, partitions are possible, so you cannot drop P. A single-node database is the only true CA system β€” and it isn't distributed.

Beyond CAP: PACELC

CAP only describes behavior during a partition. PACELC extends it: if there is a Partition, choose between Availability and Consistency; Else (normal operation), choose between Latency and Consistency. This captures the everyday trade-off that strong consistency costs latency even when nothing is broken.

Consistency Is a Spectrum, Not a Switch

Modern systems tune this per operation. DynamoDB lets you request strongly consistent reads when correctness matters and eventually consistent reads when speed matters. The real engineering skill is identifying which data needs strict consistency (payments, inventory) and which can tolerate brief staleness (view counts, feeds).

Frequently Asked Questions

Can a system have all three of C, A, and P?

Not simultaneously. During a network partition you must give up either consistency or availability. When there is no partition, a well-designed system can offer both β€” but it cannot guarantee all three at once under partition.

Is the CAP theorem still relevant?

Yes, as a mental model, but treat it as a starting point. PACELC and tunable consistency levels describe real systems more precisely. CAP's lasting lesson is: partitions are inevitable, so decide your partition behavior deliberately.

Is SQL CP and NoSQL AP?

Not reliably. It depends on configuration. A distributed SQL database can be CP, and some NoSQL stores can be tuned toward consistency. Judge each system by its replication and quorum settings, not its query language.

Partitions aren't a choice β€” they're a fact of networks. CAP is really about what you do when one happens.

β€” alokknight Engineering