CAP Theorem: Why You Can't Have It All

•Venkata Lokesh P
System DesignCAP TheoremDistributed SystemsBeginner

Imagine your stadium's booking system from before. You've now got multiple servers spread across data centers, each holding a copy of the same data, so no single server is a bottleneck.

One day, the network cable between two of those servers gets cut. Just for a few seconds. Nothing dramatic: these things happen all the time in the real world.

But in that gap, a request comes in. And your system has to answer a question it can't dodge: do you give the user a possibly wrong answer, or no answer at all?

That question, and the fact that you're always forced to pick one, is the entire CAP theorem.


First, the Three Letters

CAP stands for three properties a distributed system (one made of multiple servers working together) might have:

  • C: Consistency: every server gives you the same answer, always up to date. If you write a value and immediately read it back, you get exactly what you just wrote, no matter which server answers.
  • A: Availability: every request gets a response. Not an error, not a timeout. The system always answers, even if a server somewhere is having a bad day.
  • P: Partition Tolerance: the system keeps working even when a network partition happens, meaning some servers temporarily can't talk to each other, even though each one is still up and running fine on its own.

A "partition" doesn't mean a server crashed. It means the network between two working servers broke. Both servers are alive. They just can't hear each other for a bit.

The CAP theorem says: you can't have all three, all the time. And specifically, the moment a partition actually happens, you have to pick between C and A. P isn't really optional in a real distributed system (networks fail, that's just physics and cheap routers), so the real-world version of CAP is: "when the network splits, choose Consistency or Availability."


Walking Through the Scenario

Here's the picture that makes this concrete. Two servers, Node A and Node B, both hold a copy of the same value, x.

  1. Client A writes x = 5 to Node A. Node A updates instantly.
  2. Right then, the network link between Node A and Node B breaks. Node B never gets told about the update. It's still sitting on the old value, x = 3.
  3. Client B sends a read request to Node B, asking for the current value of x.

Node B is now stuck. It genuinely does not know if x is still 3, or if it changed somewhere it can't reach. It has exactly two options:

  • Refuse to answer. Block the read, or return an error, until it can reconnect with Node A and confirm the real value. This keeps every answer correct, but it means Client B gets nothing right now. This is choosing Consistency.
  • Answer anyway. Return x = 3, the only value it has, even though it might be wrong. Client B gets a fast, useful-looking response, just maybe a stale one. This is choosing Availability.

There is no third option where Node B gives Client B a guaranteed-correct answer and answers immediately, because the one piece of information that would make both possible ("what did Node A just do?") is exactly what the broken network is withholding.

This isn't a design flaw you can code your way around. For that brief window where the network is split, correctness and responsiveness are mutually exclusive. One of them has to give.


Why Call It "CAP" Instead of Just "C vs A"?

Because partition tolerance isn't free, and pretending otherwise is the mistake beginners make.

You could design a system that assumes the network never splits: that's a CA system: it gives you Consistency and Availability, as long as nothing ever breaks between servers. That sounds great until you remember: real networks, across real data centers, over any long enough stretch of time, will have a hiccup. Cables get unplugged. Routers reboot. A cloud provider has a bad afternoon. A system that silently assumed this would never happen doesn't get to choose "neither C nor A," it just breaks in some undefined way the day it actually occurs.

So in practice, almost every real distributed system has already accepted partition tolerance as a given, and the only live question is what it does when a partition hits:

ChoiceWhat it meansExample
CP (Consistency + Partition tolerance)During a split, refuse or delay requests rather than risk a wrong answer.A bank's core ledger: it would rather show an error than a wrong balance.
AP (Availability + Partition tolerance)During a split, always answer, accepting the data might be briefly stale.A social feed: showing yesterday's like count is fine, showing nothing is worse.
CA (Consistency + Availability, no P)Only works if partitions never happen, not realistic for anything spread across multiple machines.A single-server database. The instant you add a second server, you're exposed to CAP again.

It's Not "Pick One Forever": It's "Pick One, Per Partition"

One thing that trips people up: CAP isn't a label you slap on a whole system once and forget about. It's a decision that kicks in specifically while a partition is happening. The rest of the time, with the network healthy, there's no tradeoff at all: every node can be both consistent and available, because the information to stay correct is always reachable.

It's also not all-or-nothing across an entire product. A real system often makes different CAP choices for different kinds of data, because the cost of being wrong isn't the same everywhere:

  • Checking out and charging a card? Lean CP. A failed payment is annoying, a double charge or a lost payment is a real problem.
  • Showing someone's follower count or a "last seen online" status? Lean AP. Being a few seconds stale is invisible to the user, refusing to load the page is not.

Good system design isn't "are we CP or AP." It's "which parts of this system need CP, and which parts can get away with AP," and being deliberate about that line, instead of inheriting it by accident from whatever database you happened to pick.


Quick Recap

ConceptWhat It Means
Consistency (C)Every server returns the same, most up-to-date answer
Availability (A)Every request gets a response, never an error or a hang
Partition Tolerance (P)The system keeps functioning even if servers can't reach each other
The TheoremDuring an actual network partition, you must choose C or A, not both
CP systemCorrectness over responsiveness, may refuse to answer during a split
AP systemResponsiveness over correctness, may answer with stale data during a split
CA systemOnly possible with zero partitions, unrealistic for real multi-server systems