The CAP theorem says that when the network between the machines in a distributed system breaks, each machine has to choose: answer with data that might be out of date, or refuse to answer until it can be sure. Knowing which one your system picks tells you exactly how it will misbehave on a bad day, which is why it turns up in so many system design interviews.
The three letters
A distributed system is several machines, called nodes, that hold copies of the same data and talk to each other over a network. CAP names three properties you would like it to have.
Consistency
Every read sees the most recent write, as if there were only one copy of the data. If you update your address and then read it back from any node, you get the new address. The formal name for this is linearisability.
This is not the C in ACID. ACID's consistency means a transaction leaves the database obeying its rules (no negative balances, no orphaned rows). CAP's consistency is about copies agreeing with each other.
Availability
Every request that reaches a working node gets a real answer, not an error or a timeout. There is no promise that the answer is the latest one, only that there is one.
This is also a narrower idea than everyday 'availability'. A system can have excellent uptime and still not be available in the CAP sense, because it deliberately turns some requests away during a network fault.
Partition tolerance
A partition is a network fault that splits the nodes into groups that can't reach each other. Messages between the groups are lost or delayed indefinitely. Partition tolerance means the system keeps running, in some form, while that is going on.
Why partition tolerance isn't optional
Networks fail. A switch dies, a cable is cut, a cloud region loses its link to another, or a node pauses for so long that its peers give up on it. From the inside, a node can't tell a slow peer from a dead one or from a broken link: all it sees is silence.
So if you run more than one machine and they talk over a network, partitions will happen whether you plan for them or not. A single database server never has a partition, but it isn't distributed either, and it has no copy to fall back on when it fails. That is why 'pick any two of the three' is misleading. For a real distributed system, P comes with the territory, and the choice that matters is between C and A while a partition lasts.
Wondering how this was made? How we make these