October 4, 2026 · Yunus Emre Vurgun
What Is the CAP Theorem in Distributed Systems?
The CAP theorem states that a distributed data store can simultaneously guarantee only two of three properties: Consistency, Availability, and Partition tolerance. Since network partitions are unavoidable in any real distributed system, the practical choice is between consistency and availability whenever a partition happens. Modern databases often tune this trade-off per operation rather than picking one side forever — but you still need to understand the theorem to choose wisely.
The three letters: C, A, and P
Consistency in CAP means linearizability: every read receives the most recent write or an error. If you update your profile photo and a friend loads your page, they see the new photo — never the old one, no matter which replica serves them. Availability means every request receives a non-error response, even if some nodes are down: the system keeps answering, though the answer might be stale. Partition tolerance means the system keeps operating despite arbitrary messages being dropped between nodes — the network can split the cluster into islands that cannot talk to each other, and each island still does something sane.
The crucial insight is that partition tolerance is not optional. A system that stops working the moment a network cable fails is not a distributed system worth running, so every real distributed database must tolerate partitions. That collapses the famous "pick two" into a simpler question: when a partition occurs, do you stay consistent (CP) or stay available (AP)? The single-machine "CA" corner of the triangle only exists while there is no distribution at all. For the formal definitions and related vocabulary, see the CAP theorem reference.
Why you cannot have all three
Imagine a two-node database, Node 1 and Node 2, with the network link between them severed. A client writes balance = 100 to Node 1. Now another client reads balance from Node 2. Node 2 has a dilemma: it cannot reach Node 1, so it does not know about the write. If it answers with its stale value, the system is available but inconsistent. If it refuses to answer until the partition heals, the system is consistent but unavailable. There is no third option — information cannot travel across a broken link.
This is the whole proof, and it explains why the trade-off only binds during a partition. When the network is healthy, a system can be both consistent and available; replication lag is typically milliseconds. CAP governs the failure mode, not the steady state. It also explains why single-datacenter systems with reliable networks can act effectively CA for years — until the day a switch fails or a cloud region splits, and the choice they never made gets made for them, usually at 3 AM.
CP vs AP vs CA: real database examples
Databases advertise where they sit on this spectrum, and matching the choice to your workload is the practical skill:
| Category | Behavior during partition | Examples |
|---|---|---|
CP (consistent) | Minority side refuses reads/writes until it can sync. | etcd, ZooKeeper, HBase, MongoDB (majority settings). |
AP (available) | All sides keep serving; conflicts merge after healing. | Cassandra, DynamoDB, CouchDB, Riak. |
CA (single-node) | No partition possible; traditional ACID guarantees. | Postgres, MySQL on one server. |
Pick CP when correctness beats uptime: financial ledgers, inventory counts, configuration stores, anything where two nodes disagreeing is worse than one node waiting. Etcd, which stores Kubernetes cluster state, would rather halt than diverge — a split brain there would be catastrophic. Pick AP when uptime beats exactness: shopping carts, social feeds, session data, sensor ingestion. DynamoDB-style carts famously merge after partitions because losing a customer's cart is worse than briefly showing a stale one. These guarantees interact with transaction semantics too; the ACID vs BASE comparison shows how consistency models shape the consistency side of the triangle.
Does the CAP theorem still matter with modern databases?
Yes, but more subtly than the slogans suggest. Modern systems rarely plant one flag; they offer tunable consistency. Cassandra lets you require a quorum of replicas per read or write: quorum operations lean CP, single-replica operations lean AP, and you can mix them in one cluster. Cosmos DB exposes five consistency levels from strong to eventual. Even Postgres, the archetypal CA database, becomes a distributed system with its own CAP choices the moment you add read replicas or synchronous standby — synchronous commit is a CP choice, asynchronous replication an AP one.
What the theorem still forbids is magic: no database, however modern, can promise that both sides of a network split keep serving fresh data. Vendor claims of "CA plus partition tolerance" deserve skepticism — press for what happens during the split, because that is where CAP lives. The theorem also says nothing about latency, which is why its successor, PACELC, adds the everyday trade-off: even without partitions, you choose between latency and consistency on every replicated write. A machine-readable summary of the theorem and its categories is available in the CAP theorem dataset.
Beyond CAP: PACELC and tunable consistency
PACELC extends CAP with one sentence: if there is a Partition, choose Availability or Consistency; Else, choose Latency or Consistency. Replicated writes can wait for every replica (consistent but slow) or acknowledge after one (fast but briefly divergent). Most applications live in the "else" branch 99.9% of the time, so this half of the trade-off often matters more day to day than the partition half.
Practical advice follows from both halves. First, decide per workload, not per company: your billing ledger and your product-view counter can and should make different choices. Second, prefer tunable systems when workloads are mixed, and set explicit consistency levels rather than accepting defaults blindly. Third, design for convergence: idempotent writes, last-write-wins with vector clocks, or CRDTs for counters and sets make the AP side far less scary. Fourth, test the partition behavior — chaos tools that sever links between nodes will teach you more about your CAP posture in an afternoon than a month of whiteboard debates. CAP is not a cage; it is a map of the terrain every distributed system must cross.