CAP and PACELC

Topics Covered

The CAP Theorem

The statement

The proof in one picture

What the theorem does not say

Pick two is wrong

CP and AP in practice

Availability is per request

Why the theorem still matters

The history of the conjecture

Requests that never arrive

A partition from the inside

Durations and blast radius

The CAP theorem is the most cited and most misunderstood result in distributed systems. It is often summarized as pick two of consistency, availability and partition tolerance, a slogan that is misleading in several ways. This lesson states what the theorem actually says, walks through why it is true, explains what it does not say, and then introduces PACELC, which captures the trade off that matters far more often in practice: latency versus consistency when the network is healthy.

The statement

Eric Brewer presented the CAP conjecture in a keynote at the Symposium on Principles of Distributed Computing in 2000, and Seth Gilbert and Nancy Lynch proved a precise version in 2002. In the precise version, consistency means linearizability, a single register that behaves as if there were one copy. Availability means that every request received by a non failing node must eventually receive a response, not an error. Partition tolerance means the system continues to operate even when the network drops arbitrarily many messages between nodes. The theorem says that no system can provide all three: when a partition happens, a system must give up either linearizability or availability.

The proof in one picture

The proof is short. Take two nodes, each holding a copy of a register initially 0, and partition them so no messages pass. A client writes 1 to the first node. If the system is available, the first node must eventually acknowledge the write. Then another client reads from the second node. If the system is available, the second node must eventually answer. It cannot know about the write, because no messages pass, so it answers 0. But the write completed before the read began, so linearizability requires 1. Either one of the nodes refuses to answer, giving up availability, or the read returns 0, giving up linearizability.

During a partition, the side that missed a write can either answer with old data or refuse. There is no third option.

What the theorem does not say

First, partition tolerance is not optional. Networks do partition, as earlier lessons showed, so a distributed system cannot choose to give up P. The real choice is what to do during a partition: keep answering with possibly stale data, called AP, or refuse some requests to stay linearizable, called CP. Second, the choice is only forced during a partition. When the network is healthy, a system can be both linearizable and available. Third, the theorem uses specific definitions. Consistency means linearizability, not the C in ACID. Availability means every non failing node answers every request, a very strong requirement that few real systems even attempt.

Pick two is wrong

The pick two framing suggests three options: CA, CP and AP. CA would mean consistent and available but not partition tolerant, which in practice means a system that behaves arbitrarily when the network partitions. That is not a design choice, it is a bug. A single node database is sometimes called CA, but it is not a distributed system, and as soon as clients reach it over a network that can partition, clients on the wrong side see it as unavailable. Brewer himself wrote in 2012 that the pick two formulation was misleading and that designers should think about how to handle partitions rather than about which letter to drop.

CP and AP in practice

A CP system, during a partition, refuses or delays operations on the side that cannot reach a majority. Systems built on Raft or Paxos, such as etcd, ZooKeeper, Consul and Spanner, behave this way: the minority side cannot elect a leader or commit writes, so its clients see errors or timeouts. An AP system keeps accepting operations on both sides and reconciles afterward. Dynamo style stores such as Cassandra and Riak at low consistency levels, DNS and most caches behave this way: every reachable replica answers, possibly with stale data, and conflicts are resolved after the partition heals.

Availability is per request

A more useful reading of CAP is per request rather than per system. During a partition, a CP system is still available to clients on the majority side, and only clients stuck with the minority lose service. An AP system is available to all clients but may give stale or conflicting answers to some. Many systems let clients choose per request: Cassandra with consistency level ONE behaves AP for that request, while QUORUM behaves closer to CP, refusing if a quorum cannot be reached. DynamoDB offers eventually consistent reads and strongly consistent reads that fail if the leader replica is unreachable.

Why the theorem still matters

Despite its narrowness, CAP captures a real constraint. Any system that offers linearizable operations must accept that some clients will be refused during some partitions, and any system that promises to always answer must accept stale or conflicting results. Recognizing which side of this line a given operation sits on, and designing the user experience accordingly, prevents both false promises and overengineering. It also explains why systems that claim to beat CAP usually either redefine one of the terms or rely on partitions being rare, such as Spanner relying on Google private network.

The history of the conjecture

Brewer arrived at the conjecture from experience building Inktomi, one of the first large scale web search engines, in the late 1990s. Inktomi clusters favored availability: when nodes failed, the service kept answering with whatever data the surviving nodes held. Brewer observed that the database community optimized for consistency through ACID transactions while internet services optimized for availability through what he called BASE, basically available, soft state, eventually consistent. CAP was his attempt to explain why the two camps made different choices, and the keynote framed it as a spectrum rather than a strict theorem. The formal proof came later and, in making the statement precise, narrowed it considerably.

Requests that never arrive

One subtle point in the proof is that availability only applies to requests that reach a non failing node. A client that cannot reach any node at all is not covered, since no system can answer a request it never receives. This is why a CP system is still considered to offer something useful: clients on the majority side of a partition are served. The theorem bites specifically for clients that can reach a node, just not one that can coordinate with the rest. In geo distributed systems, those are often the clients in the region that has been cut off, which is exactly where local users expect the service to keep working.

A partition from the inside

It is worth imagining a partition from the perspective of a single replica. It sees requests arriving from clients and silence from some peers. It does not know whether the peers crashed, whether the links are down or whether the peers are simply slow. It does not know whether the other side is still accepting writes. Every decision it makes, answering or refusing, must be made with that uncertainty. The CAP proof formalizes exactly this situation: two nodes, each unable to learn what the other has done, each forced to act on local knowledge alone.

Durations and blast radius

Partitions vary enormously in scope and duration. A single top of rack switch failure may isolate a few servers for minutes. A misconfigured routing change may split a data center for an hour. A cut undersea cable may isolate a region for days, though usually with degraded rather than zero connectivity. The CAP choice matters most for the partitions that last longer than client timeouts and isolate users from the majority. Understanding the likely failure modes of the actual network, rather than an abstract partition, helps decide how much effort partition mode deserves.

Seen this way, CAP is less a classification scheme than a reminder that every replica, at some point, must act without knowing what its peers have done, and that the system designer decides in advance how it should act.

Partitions force a choice, not a letter

During a network partition, a replica that cannot reach the others must either answer with possibly stale data or refuse. Partition tolerance is mandatory, the choice applies only during partitions, and it can be made per operation rather than per system.