Skip to content

Lesson 6 of 13 · 14m

CAP Is a Question About Partitions

CAP does not ask you to pick two of three; it asks what each part of your system does on the day the network splits.

CAP is the most misquoted result in the field. Brewer's 2000 conjecture, formalized by Gilbert and Lynch in 2002, says a distributed system cannot simultaneously guarantee Consistency (linearizability), Availability (every request to a live node gets a non-error response), and Partition tolerance (the system keeps operating when the network drops messages between groups of nodes). The popular rendering — "pick two of three" — is wrong in a way that matters: partition tolerance is not a dial. Partitions happen — a bad cable, a misconfigured switch, an AZ link flapping, an asymmetric drop that lets A reach B but not C. The choice CAP imposes only exists during a partition, and it is binary: when the partition starts, do you refuse to answer (CP), or do you answer with possibly-stale, possibly-divergent data (AP)?

Abadi's PACELC makes the full trade visible: if there is a Partition, choose between Availability and Consistency; Else, in normal operation, choose between Latency and Consistency. The else-branch is where most real decisions live. Synchronous replication picks consistency and pays the write latency of the slowest required replica — a cross-region sync replica prices every commit at WAN round-trip time. Asynchronous replication picks latency and pays in staleness — which is why "your replica is behind" from the previous lesson is an else-branch trade, not a failure.

One more thing about the P: partitions are not always symmetric. A split where A can reach B but B cannot reach A — a dropped return path, a one-way firewall rule, a congested egress — produces behavior no diagram prepared you for: the leader happily accepts writes while half the cluster cannot see them. Latency is also indistinguishable from a slow partition: a node that answers in ninety seconds is, to everyone waiting on it, partitioned. Your timeouts draw the boundary, which is why the previous module kept insisting on real numbers.

GitHub spent 24 hours learning this in public

October 21, 2018: routine maintenance severed the link between GitHub's US East Coast network hub and its primary East Coast data center for 43 seconds. The MySQL failover tooling (Orchestrator) did its job — it promoted primaries in the West Coast data center. Application servers in the East kept writing to the old primary for a window. Two primaries, divergent writes, and a site that stayed degraded for over a day while engineers reconciled the divergent state by hand. Forty-three seconds of partition bought a day of reconciliation. That is what CP's unavailability window and AP's divergence actually look like when they leave the whiteboard.

The same trade runs in miniature inside every coordination system. etcd and ZooKeeper are CP: the minority side of a partition refuses writes — unavailable by design, correctly. Cassandra is AP: every node keeps serving, the partition ends, and anti-entropy plus last-write-wins decides which writes survived. Neither is wrong. Both are decisions somebody made on your behalf if you did not make them yourself.

The wrong mental model

"We chose a CP system, so we're consistent." Two problems. First, CP governs partition behavior; a CP store still serves stale serializable reads, still has failover windows, still has to be told what to do when it loses quorum — which is unavailability, whichever way the acronym leans. Second, your system is not a database: the load balancer, the app tier, the background worker, and the cache each get their own C-or-A moment during a partition, and they rarely make the same choice unless someone designed it. "We're CP" applied to a stack whose frontend happily serves a 60-second cache is branding, not engineering.

What to actually do

Decide the partition policy per subsystem and write it down before the incident decides for you. Refuse writes where divergence is unrecoverable — payments, seat allocation, key rotation. Serve stale where convergence is cheap — feeds, catalogs, dashboards. Build the reconciliation tooling before you need it: the cost of AP is not the partition, it is the merge. And test the behavior: iptables -A INPUT -j DROP and tc qdisc add ... netem loss on a staging link will show you in an afternoon which of your services picked availability without telling you.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.