Deep Dive
high level designdistributed systemsconsistency

CAP Theorem: The Choice You Only Make When the Network Breaks

Everyone quotes 'pick 2 of 3' and everyone is wrong. CAP is a decision forced only during a partition — and PACELC is the sharper lens for the 99.9% of the time when the network is fine.

·12 min read
Medium

3:02 AM. A fiber cut severs the link between your two datacenters. Each side still has half your database replicas, each side is still up, and each side can still hear its own clients — they just can’t hear each other. A write lands in the east region. A read for the same key arrives in the west region a millisecond later.

You now have exactly two options, and no third. Either west rejects the read until it can confirm it isn’t stale — sacrificing availability to stay correct. Or west serves the value it has — sacrificing correctness to stay up. There is no button labeled “both.” The partition already happened; you don’t get to opt out of it. The only thing you control is which promise you break.

That fork in the road is the CAP theorem. Not a menu of three features to shop from — a single, unavoidable decision that the network makes you make.

Seth Gilbert and Nancy Lynch’s 2002 paper turned Eric Brewer’s informal 2000 conjecture into a proof. And read the statement carefully, because the proof is what dismantles the myth: it says you cannot have all three at once. It does not say you get to keep whichever two you like as a permanent design setting.

The intuition: two ATMs and one severed line

Picture one bank account with ₹10,000, mirrored across two ATMs in two cities connected by a leased line. Normally they gossip every withdrawal, so both always agree on the balance.

Now the line goes down. A customer walks up to the Mumbai ATM and asks to withdraw ₹8,000. The machine faces the same 3 AM fork:

  • Refuse until the line is back (choose consistency). No double-spend is possible, because Mumbai won’t act without confirming Delhi hasn’t already drained the account. But a customer standing at a working ATM gets turned away — you gave up availability.
  • Dispense the cash (choose availability). The customer is served instantly. But Delhi might dispense against the same ₹10,000 a second later, and now the account is overdrawn — you gave up consistency.

The severed line is the partition. It is not a design choice; it’s a fact of physics and fiber. What you design is the ATM’s answer when the line is down.

The members-only continuation walks the partition proof node-by-node with a live diagram, breaks down the three CAP myths interviewers pounce on, contrasts CP vs AP with what each one actually sacrifices, introduces PACELC as the sharper everyday lens, and closes with an interview corner — an interactive quiz plus an explain-with-AI reveal.

Members only

Keep reading with Premium

You've reached the members-only part of this deep-dive — the full implementation, the interactive ring simulator, and the step-by-step walkthrough. Unlock it with a membership.