Worked examples — CAP theorem — consistency, availability, partition tolerance
This page is the drill hall for the CAP topic. The parent note told you the idea: during a network split you must pick between staying Correct and staying Answering. Here we hit every kind of situation that idea can throw at you — one worked example per cell — so no exam question can surprise you.
Before any symbol appears, some plain-word reminders (we will not use anything until it is anchored below):
We write a stored value as , and a specific version of it as (old) or (new). The little number is just a timestamp label — "which write happened first". Nothing more.
The scenario matrix
Every CAP question is really one of these case classes. The examples below fill in each row.
| # | Case class | What is being tested | Example that hits it |
|---|---|---|---|
| 1 | No partition (healthy network) | Both C and A available; PACELC L-vs-C | Ex 1 |
| 2 | Partition + choose CP | Refuse to answer, keep correct | Ex 2 |
| 3 | Partition + choose AP | Answer anyway, may be stale | Ex 3 |
| 4 | Quorum boundary (majority side vs minority side) | Which side stays alive | Ex 4 |
| 5 | Degenerate: single node () | Is CAP even meaningful? | Ex 5 |
| 6 | Degenerate: total split (every node isolated) | Limiting extreme | Ex 6 |
| 7 | Real-world word problem (money vs sales) | Choosing C or A from business cost | Ex 7 |
| 8 | Exam-style twist ("CAP's C = ACID's C?") | Concept trap | Ex 8 |
| 9 | Limiting behaviour (partition duration → 0 and → ∞) | Eventual consistency limit | Ex 9 |
The two axes of this matrix are: (a) is there a partition? (no / yes) and (b) if yes, which property do you sacrifice? (C or A). The degenerate rows (5, 6) test the edges of those axes — one node, or infinitely many isolated nodes.
Figure s01 below draws exactly these two axes: the vertical dashed line splits "no partition" (left, teal bubble = PACELC) from "partition present" (right), and the two right-hand bubbles show the CP/AP fork. Use it as the map for the whole page — each example lands in one bubble.

Example 1 — No partition, PACELC lives (Cell 1)
Forecast: Guess now — does sync or async give the reader the latest value, and roughly how long does each write take?
-
Sync latency. The leader sends to 4 followers in parallel and waits for the slowest ack (acknowledgement). One round trip = send () + ack back () . Why this step? "Wait for all" means the reply cannot happen until the last ack arrives; sent in parallel that is one round-trip time, not four.
-
Async latency. Leader writes locally and replies immediately: of network wait. Why this step? Async means "don't wait for followers", so the network delay is removed from the client's path.
-
Which gives a fresh follower read? Only sync. In async, a follower may still hold when a client reads it, because the copy is still in flight. Why this step? Freshness on any node requires that node to have received the write before the read — that is exactly what waiting for its ack guarantees.
Verify: Sync , async ; sync async extra latency, the "cost of C". Units are milliseconds throughout. ✓
Example 2 — Partition, choose CP (Cell 2)
Forecast: Will answer , answer , or refuse?
-
checks quorum. With 3 nodes, a strict majority is (using the floor definition above). Alone, counts only itself: . Why this step? CP systems require a majority to serve, so first they ask "am I in the majority?".
-
refuses. Since , returns an error / timeout, not data. Why this step? never heard ; the only way to guarantee it never hands out a stale value is to hand out nothing. Losing A protects C.
-
Client sees no stale data. Correct: the client got an error, never the wrong . Why this step? The definition of Consistency = "most recent write or an error". An error is allowed; a stale value is not.
Verify: majority ; minority side has node must reject. No stale value returned C preserved. ✓
Example 3 — Partition, choose AP (Cell 3)
Forecast: Answer with data, or refuse like Ex 2?
-
answers with what it has. It returns immediately. Why this step? AP's promise is "a non-failing node always gives a non-error response". is up, so it must answer — even though is stale.
-
Mark the value stale. The read returned old data; A is kept, C is lost for this moment. Why this step? literally has no way to know exists — the partition guarantees it. So the only response it can give is the old one.
-
Heal + reconcile. When the link returns, receives and overwrites (last-write-wins by timestamp, or a merge). This is Eventual Consistency. Why this step? AP doesn't abandon correctness forever — it defers it. Given no new writes, all replicas converge to .
Verify: During partition returns (stale) A kept, C lost. After heal, final value on all nodes (single latest write) convergence. ✓
Example 4 — Quorum boundary: which side lives? (Cell 4)
Forecast: Guess which side stays available in each split.
-
Compute the quorum. For , majority (floor of is ). Why this step? A "quorum" is the smallest group forming a strict majority; two disjoint groups can never both reach it, which is exactly why it prevents split-brain.
-
3-vs-2 split. The 3-side has → serves. The 2-side has → rejects. Why this step? Only the side with a majority can safely accept writes without risking two conflicting "latest" values.
-
4-vs-1 split. The 4-side has → serves. The 1-side rejects. Why this step? Same rule; the bigger the majority side, the more failures it can still absorb.
-
Why two majorities can never coexist. If both sides served, we'd have two "latest" writes — a split-brain. Since , two disjoint quorums cannot both fit inside 5 nodes. Why this step? This inequality is the whole reason quorums guarantee C: any two quorums must overlap in at least one node, so they can't disagree silently.
Figure s02 below draws the 3-vs-2 split: the teal circles (left, size 3) reach the quorum and serve; the plum circles (right, size 2) fall short and reject. The orange dashed line is the partition. Read it as the picture of steps 2 and 4.

Verify: quorum . In , sizes (serve), (reject). In , (serve), (reject). Two quorums need nodes → impossible → no split-brain. See Replication and Quorums. ✓
Example 5 — Degenerate: a single node (Cell 5)
Forecast: Is a single-node DB CP, AP, or "CAP doesn't apply"?
-
Count the links that could break. A partition is a break on a link between two nodes. The number of possible node-pairs (links) is (the "n choose 2" defined above). For : . Why this step? Zero links means there is literally nothing to partition — the CAP trade-off is never triggered.
-
What if the client can't reach the node? That's a client outage, not a CAP partition. If reachable, the single copy is always the latest (nothing to disagree with) and it answers. Why this step? With one copy, C is automatic (no disagreement possible) and A holds whenever the node is up.
-
Classification. A single node is trivially CA — but only because never arises. It is not "beating the theorem"; it simply isn't distributed. Why this step? CAP applies to Distributed Systems with replicas. is the degenerate edge.
Verify: Number of inter-node links no partition possible C and A both trivially hold. ✓
Example 6 — Degenerate: everyone isolated (Cell 6)
Forecast: Guess how many nodes stay writable.
-
Quorum for . Majority . Why this step? Same majority rule; note even ties ( nodes, half is ) need strictly more than half.
-
Each island's size. Every island has exactly node. for all of them. Why this step? No island can reach the quorum of 3, so none may accept writes.
-
Whole-system write availability. of nodes can serve writes → CP system is fully unavailable for writes in a total split. Why this step? This is the limiting extreme: as the partition shatters everything, CP write-availability drops to zero. (An AP system, by contrast, would let all 4 keep answering and reconcile later.)
Verify: quorum ; each island size writable nodes . Fraction available (CP) . ✓
Example 7 — Real-world word problem: money vs sales (Cell 7)
Forecast: Which service should be CP and which AP? Guess before computing.
-
Bank, if it went AP (answer with a possibly-stale balance). Worst case: each of the 1000 reads enables one overdraw, so cost \le 1000 \times \500 = $500{,}000$. Why this step? Multiply "number of requests" by "dollar cost per wrong answer" to price the stale option. This is the money you lose by keeping A and sacrificing C.
-
Cart, if it went CP (refuse the add during the split). Each rejected add loses one sale, so cost = 1000 \times \3 = $3{,}000$ in lost revenue. Why this step? For the cart the cost sits on the refuse side, not the stale side — pricing this shows what keeping C (and sacrificing A) costs here.
-
Compare and decide. Bank: choosing AP risks up to $500 000, while choosing CP (refuse the withdrawal) risks $0 of lost money — only inconvenience. Cart: choosing CP costs $3 000 in lost sales, while choosing AP (accept the add, merge later) risks only a briefly-wrong cart. So bank → CP, cart → AP. Why this step? You never pick C or A in the abstract — you pick whichever mistake is cheaper. The dollar figures make the trade-off concrete, exactly the strict-vs-relaxed spirit of ACID vs BASE.
Verify: AP-bank worst cost =1000\times500=\500{,}000=1000\times3=$3{,}000500000 > 3000$, the bank avoids the larger loss by choosing CP and the cart avoids its loss by choosing AP. Units are dollars throughout. ✓
Example 8 — Exam twist: is CAP's C the same as ACID's C? (Cell 8)
Forecast: Guess true or false before reading.
-
Define CAP-C. It means linearizability: all replicas agree on one latest value across nodes. Why this step? CAP-C is about cross-node agreement in a distributed system — the "Correct" slogan from the opening definitions.
-
Define ACID-C. It means a transaction never breaks the database's invariants (e.g. "account balance ≥ 0", foreign keys valid) — a single-node correctness rule. Why this step? ACID-C is about rules within a transaction, independent of replication or partitions.
-
They are different axes. A CP system can be perfectly linearizable yet run a transaction that violates a business rule; an ACID system on one node has no CAP-C question at all. Why this step? Conflating them is the trap: same letter, unrelated meanings.
-
Answer: FALSE. Why this step? CP guarantees agreement about which value; ACID-C guarantees the value obeys the rules. Neither implies the other.
Verify: CAP-C ≡ linearizability (cross-replica); ACID-C ≡ invariant preservation (intra-transaction). Distinct definitions ⇒ CP ⇏ ACID-C ⇒ statement is False. See ACID vs BASE. ✓
Example 9 — Limiting behaviour: partition duration → 0 and → ∞ (Cell 9)
Forecast: What happens to staleness at the two extremes?
-
Stale-read count model. Number of stale reads (rate × time). Why this step? Over a window at rate , the total is the product — a simple linear accumulation.
-
Limit . . A partition that heals instantly produces essentially zero staleness → looks like full consistency. Why this step? This is why brief blips barely matter for AP systems — the shorter the split, the closer AP behaves to CP.
-
Limit . . Staleness grows without bound; but once the link heals (any finite time), Eventual Consistency still makes all replicas converge to the latest value. Why this step? AP never promises no staleness — only that after healing, with no new writes, replicas converge. Convergence is about the end state, not the count of stale reads along the way.
-
Contrast with CP. A CP system's stale reads for all (it refuses instead), at the cost of write-availability during the split. Why this step? This crystallizes the whole page: AP trades a growing for uptime; CP trades uptime for .
Verify: ; , ; post-heal replicas converge (single final value). CP: always. ✓
Recall Self-test across the whole matrix
What do C, A, P stand for in one plain word each? ::: Correct (Consistency), Answering (Availability), Partition (Partition-tolerance). Spell out CP and AP. ::: CP = Consistency + Partition-tolerance (stays correct, may refuse); AP = Availability + Partition-tolerance (stays answering, may be stale). Which cell is a single-node DB? ::: Cell 5 — degenerate, trivially CA because P never arises. In a 5-node cluster, what quorum is needed and why can't two sides both serve? ::: Quorum = 3; two quorums need 6 > 5 nodes, so they must overlap — no split-brain. As partition duration T → ∞ in an AP system, do replicas still converge? ::: Yes, after the link heals (any finite time) eventual consistency converges them; only the stale-read count grew. Is a CP database automatically ACID-consistent? ::: No — CAP-C is linearizability, ACID-C is invariant preservation; different axes. In a total 4-way split under majority quorum, how many nodes can accept writes? ::: Zero — each island of 1 is below the quorum of 3.
Connections
- Parent topic (Hinglish)
- Distributed Systems
- ACID vs BASE
- Eventual Consistency
- Replication and Quorums
- PACELC theorem
- Consensus — Paxos & Raft
- NoSQL Databases