The CAP Theorem
Hop now runs in two regions, Mumbai and Frankfurt, each with its own copy of the links. One afternoon the network link between them breaks. Both regions are healthy; they just cannot talk. A user in Frankfurt asks for a link created in Mumbai two seconds ago. What should Frankfurt say?
The rule
When the network splits, choose: answer possibly stale, or refuse.
CAP names three properties of a system that keeps copies of data on several machines:
- Consistency (C) — every read sees the most recent write, as if there were one copy.
- Availability (A) — every request to a working machine gets a non-error answer.
- Partition tolerance (P) — the system keeps running when messages between machines are lost.
Networks do fail, so P is not optional for a distributed system. The real choice appears only during a partition:
- CP — refuse or wait rather than risk a stale answer. Correct but sometimes unavailable.
- AP — answer from the local copy. Always responsive but sometimes out of date.
When the network is healthy, a system can offer both. CAP is about the bad afternoon, not every afternoon.
The shortcut
For each feature, ask: "What is worse here — a wrong answer or no answer?" Wrong is worse → CP. No answer is worse → AP.
Redirects
An existing link almost never changes. A slightly stale copy is nearly always right; a failed redirect loses a visitor. No answer is worse → AP.
The trap is thinking you can "pick CA" and skip partitions. You cannot choose whether the network fails; you only choose how to behave when it does.
Drills
Answer fast — trust the rule.
In CAP, what does partition tolerance mean?
During a partition, a CP system asked for data it cannot confirm is current will do what?
Which feature best suits an AP choice?
When is CAP's trade-off actually forced?
Why can a distributed system not simply choose "CA"?
Remember
- When the network splits, choose: answer possibly stale (AP), or refuse (CP).
- Shortcut: "what is worse — a wrong answer or no answer?" Decide per feature.
- Trap: believing you can opt out of partitions.
