What is the CAP Theorem?
The CAP theorem, told as a story about two warehouses that lose contact and must choose.
The two warehouses can't reach each other.Should they keep serving guests, or stop?
Why it's hard: you can't have both at once.Once the line breaks, you can't have both correctness and staying open.
CAP = when the line breaks, choose correctness or staying open.Close the doors (consistency), or stay open and catch up later (availability).
The scale: correctness (close) vs staying open (catch up later).Ticket booths choose correctness; info boards choose staying open.
This choice only matters when the line breaks.Day to day, there's nothing to decide.
The CAP theorem: when the line between warehouses breaks, you can't have both correctness and always-open at once — you must choose one.
The initials of Consistency, Availability, and Partition tolerance. Since network partitions must always be assumed possible, the real choice in practice is consistency vs. availability. A further refinement, PACELC, says you trade off latency vs. correctness even when nothing is broken.
When grown-ups say it
- CAP Theorem
- The rule that you can only keep two of three when the line breaks. A question every distributed system design has to answer.
- Consistency (C)
- Every counter gives the same answer. To keep this, a counter may close when the line breaks.
- Availability (A)
- Always giving some response. But that answer might not be the latest.
- Partition Tolerance (P)
- The system keeps running even when the line is cut. In practice, you have to assume this will happen.
- Network Partition
- The event where counters lose contact. The exact situation that forces the CAP choice.
- PACELC
- An extension: even without a break, you trade latency vs. correctness. CAP covers only the break; PACELC covers every day.
- Strong Consistency
- The promise of always showing the latest, correct answer. Usually preferred wherever money is involved.
- Eventual Consistency
- The promise that things match up eventually, even if a bit late. → the inventory board that catches up a little late