Skip to the post

CAP theorem explained: what you really give up

The CAP theorem explained in plain English: what C, A and P mean, why 'pick two' misleads, how to choose CP or AP per feature, and PACELC.

· 7 min read · Fundamentals

You've probably heard the CAP theorem as "consistency, availability, partition tolerance: pick two". It's one of the most quoted ideas in system design, and that short version sends a lot of interview answers the wrong way.

Here's the CAP theorem explained the way it's actually useful. It says what a system that keeps several copies of its data must give up when the network splits. And there's a second trade-off, which costs you every day even when nothing is broken. By the end you'll be able to turn CAP into a decision for each feature, which is what interviewers want to hear.

What does the CAP theorem say?

Eric Brewer first proposed it as a conjecture in 2000. Two years later, Seth Gilbert and Nancy Lynch at MIT turned it into a formal proof. It talks about a system that keeps copies of the same data on several machines, called replicas. Its three words have narrow meanings:

  • Consistency (C) means a read always returns the most recent write that finished, just as if the data lived in one place. (It's a different C from the one in ACID, which means a transaction never breaks the database's rules.)
  • Availability (A) means any machine that hasn't crashed answers every request it gets with a proper response, never an error.
  • Partition tolerance (P) means the system keeps working when messages between machines are lost, for example when a network link fails.

The theorem says you can't have all three while the network is split. Once the replicas can't talk to each other, each one must either refuse some requests or risk giving out-of-date answers.

A simple picture: two ticket booths

A stadium sells seats from two ticket booths at opposite gates. They share one seating plan and phone each other after every sale. One evening the phone line goes dead. A fan at the north gate asks for seat 14C. The north booth has two choices:

  • Stop selling until the line is back. No seat is sold twice, but fans are turned away.
  • Keep selling from its own copy of the plan. Fans are served, but the south booth might sell 14C too, and someone sorts it out later.

There's no third choice while the line is dead. Map it onto the real parts:

  • each booth → a replica, the shared seating plan → the data, each fan → a client
  • the dead phone line → a network partition
  • stop selling → choose consistency: that's CP
  • keep selling → choose availability: that's AP
Two replicas, one in London and one in New York, with the network link between them cut. A user writes to London. London can either refuse (consistent) or accept and let the copies disagree for a while (available).
Two replicas with the link cut: refuse the write (CP) or accept it and let copies disagree (AP)

Why "pick two" is misleading

"Pick two" suggests three equal options: CP, AP and CA. But CA isn't really on the menu.

Have a guess first. Could you build a system across several machines that simply never has partitions?

You can't. Switches fail, cables get cut, a link between two data centres drops. You don't get to decide whether partitions happen. You only get to decide what your system does when one happens. So once your data lives on more than one machine, you're really choosing between two options, and only while a partition lasts:

Table comparing CP and AP during a partition: what the cut-off side does, what the user sees, what happens afterwards, and what each is good for.
CP against AP during a partition: what the cut-off side does and what users see

The other thing "pick two" hides is that most of the time there's no partition at all. During those normal hours a well-built system gives you both consistency and availability. CAP is about the rare bad moment, not about your system's whole personality.

Make sense? Good. So which should you choose, CP or AP?

CP or AP? Decide per feature, not per system

Here's the mistake that costs candidates points: picking one letter for the whole system. "We'll use Cassandra, so we're AP."

Have a guess first. Picture one social app with likes, usernames, a shopping cart and payments. Should all four behave the same way?

No. The strong answer goes feature by feature and says what the user sees:

  • Likes and view counts: AP. While the copies can't talk, carry on taking likes and showing numbers that might be slightly out. Merge the totals once the connection is back. A count that's wrong for a few minutes harms nobody.
  • Usernames: CP. A replica that can't check with the others says no, with a message like "Something went wrong, please try again." A moment's error beats two people ending up with the same username.
  • Shopping cart: AP. Let people keep adding items, and merge the two versions afterwards. Amazon built Dynamo around exactly this case.
  • Payments and the last seat or item in stock: CP. Being wrong costs real money and a support case, so refuse rather than guess.
One social app, four choices: likes and the shopping cart are AP, usernames and payments are CP, chosen by what a wrong answer would cost.
Likes and carts are AP, usernames and payments are CP: chosen by what a wrong answer costs

The letter for each feature comes down to one question: what does a wrong answer cost? A like count that's one out costs nothing. The same seat sold to two fans costs a refund and an unhappy customer.

And CP doesn't mean the whole system stops. With copies in three places, only the copy cut off from the majority says no, and often only to requests that must see the newest data. Everyone else carries on.

PACELC: the trade-off you pay every day

CAP only talks about partitions, and partitions are rare. In 2010 Daniel Abadi pointed out a trade-off that matters far more often, and named it PACELC:

If there's a Partition, choose Availability or Consistency. Else, choose Latency or Consistency.

Keeping copies in step costs time on every write, even on a perfect day. To be sure every copy has a write, you have to wait for the other copies to confirm it, and they may be on another continent.

Let's put numbers on it. A shopping cart keeps copies in London and New York. A round trip between the two cities takes about 65 ms on a good network. (These are rough, illustrative numbers.)

  • Choose consistency (EC): a London user's write waits until New York confirms it. That adds about 70 ms to every write, not counting the database's own work.
  • Choose latency (EL): the write goes to the London copy and returns in about 5 ms. New York gets it in the background, usually within a second.
Bar chart of write time for a London user: about 5 ms writing locally, about 70 ms waiting for the New York copy. Ten saves take about 0.05 s against 0.7 s.
A local write takes about 5 ms, a write that waits for New York about 70 ms

A user who saves their cart 10 times waits about 0.05 seconds in total with EL, against about 0.7 seconds with EC. The price of EL is a short window when New York can show the old cart, and if the cart is changed on two devices during that gap, you need a rule for merging the two versions. For a cart, that trade is worth it. For a seat booking, which is rare and expensive to get wrong, you pay the 70 ms.

This is the trade-off you'll actually feel in production. CAP tells you what happens on the bad day. PACELC tells you what you pay for consistency on every normal day.

Where you've met CAP and PACELC

Most real databases let you choose, sometimes for each request:

  • Amazon DynamoDB reads are eventually consistent by default, and you can ask for a strongly consistent read with one setting. A strongly consistent read uses twice the read capacity of an eventually consistent one, which is PACELC with a price tag. Its global tables copy changes between regions, usually within a second, by default. Since 2025, global tables can also run with strong consistency across Regions, where a write returns only once another Region has it.
  • Apache Cassandra lets each request choose a consistency level: ONE answers from the nearest copy, while QUORUM waits for a majority.
  • etcd and ZooKeeper, which store configuration and locks, are CP: when a member is cut off from the majority, it stops accepting writes.
  • Google Spanner is technically CP. Eric Brewer, who now works at Google, wrote in 2017 that it's "effectively CA" in practice, because partitions almost never happen on Google's own private network, and he reported more than five nines of availability for it. When a partition does happen, Spanner still chooses consistency.

That last example teaches something useful: CAP's "availability" isn't the same as high availability. A CP system can still be up 99.999% of the time.

What interviewers ask next

Once you've said "CP for usernames, AP for likes", expect a follow-up like these. Try them yourself first:

  • Is MongoDB CP or AP? (Careful: the honest answer depends on something you set.)
  • During a partition, a user on the cut-off side of a CP system tries to change their username. What exactly do they see, and for how long?
  • After an AP partition heals, two copies of the same cart disagree. How do you merge them without losing an item?

The full guide, CAP and PACELC, answers each one, with the numbers to use and what to say in two minutes.

Recap

In short, when the network splits, a system with several copies must either refuse some requests (CP) or let copies disagree for a while (AP). Partitions will happen, so CA isn't a real option, and you choose per feature by asking what a wrong answer would cost. PACELC adds the everyday trade-off: even with no partition, consistency across regions costs latency on every write. Say both, with what the user sees, and you've answered the question well.

Sources (9)
Free weekly email

One interview idea a week

A 3-minute read: one question interviewers ask, an everyday picture, the real numbers and what to say.

Check your inbox. If that address is new here, a link to confirm it is on its way. Tap it, and the first email comes within a week.

That address didn't look right. Check it and try again.

We couldn't sign you up just now. Please try again in a few minutes.

One email a week. Unsubscribe with one click from any email. Privacy

More from the blog

All posts