
Understand it
CAP is about the guarantees a distributed system can provide when communication partitions occur. A cart may use a mergeable design, but that is an explicit product and conflict-resolution choice. Quorum intersection is not by itself proof of linearizability, consensus or last-write correctness.
The CAP result is about what a distributed system can guarantee when a network partition separates participants. If it keeps accepting operations on both sides, it cannot also guarantee a single immediately consistent view of those operations. If it preserves a strong consistency contract, some requests may have to wait or fail until communication is restored. This is a narrower and more useful statement than treating consistency, availability, and partition tolerance as three features you choose on a normal day.
Describe a two-region account service during a partition. If both regions accept a withdrawal from the same balance without coordination, they may both approve against stale state and later conflict. If only the leader region accepts writes, clients in the isolated region may lose write availability. Another product, such as a collaborative notes app, may accept concurrent edits and reconcile them later. The right behavior depends on what inconsistency the domain can tolerate.
A strong interview answer names the exact consistency requirement, the operation that must remain available, and what happens during a partition. Quorums and leader election are mechanisms with their own failure modes, not magic exceptions. Define 'available' carefully: in CAP it means every request to a nonfailed node receives a response, not merely that a website usually loads. Discuss recovery too: when links heal, how are divergent versions detected, merged, or rejected?
Do not use CAP to explain every latency tradeoff. Even with no partition, a distributed system can trade consistency against latency, cost, and failure tolerance in ways CAP does not classify. Name the partition scenario first. Then discuss normal-operation choices separately, such as quorum size, placement, and caching, without calling them an escape from the theorem.
Interview follow-up: Design cart updates under a partition. How will quantities, removals, retries and concurrent adds be merged without silently losing intent?
Read the code
// Quorum sketch, not an executable consistency proof:
// N=5, R=3, W=3 makes every R/W pair intersect.
// Still specify: version ordering, concurrent writes,
// partial failures, read repair and partition behaviour.An overlapping read/write quorum still needs a protocol for versions, concurrency and partial failures.
Practice starter
// N = 5, R = 3, W = 3.
// Version ordering, concurrent writes and failed partial writes are unspecified.Try it
Describe what your service should do to writes during a partition.
What success looks like: You give one concrete behaviour rather than restating the theorem.
Check your understanding
Does read quorum + write quorum > replica count alone prove linearizable reads?
Reveal the answer
- Yes; any intersecting quorums implement a complete linearizable protocol.
- No; intersection alone does not define conflict ordering or handle incomplete operations.
- Yes; the arithmetic also makes every minority partition writable.
Overlapping sets are useful evidence, not a full protocol. CAP concerns availability and linearizability during a partition under specific definitions.
Go deeper
Common misconception: Yes; the arithmetic also makes every minority partition writable.
It does the opposite. With W = 3 of N = 5, a side with fewer than three replicas cannot complete a write, so quorums trade minority-side availability for overlap.
- Identify the contract: CAP is about what happens during a partition, not a menu of three.
- Trace the concrete example: An overlapping read/write quorum still needs a protocol for versions, concurrency and partial failures.
- Test the changed constraint: Design cart updates under a partition. How will quantities, removals, retries and concurrent adds be merged without silently losing intent?
Transfer challenge: Design cart updates under a partition. How will quantities, removals, retries and concurrent adds be merged without silently losing intent?
Connections
- Indexes and B-trees: Composite index selectivity, planner choices, skip scans and write cost
- Idempotency and Retries: Making at-least-once safe
Learn this lesson with AI
Paste this into Claude, Codex, Cursor or another agent connected to Crabrix Academy. It contains only this lesson’s public details.
I'm learning Rust with Crabrix Academy. Teach me this lesson with the Crabrix Academy tools. Lesson: CAP in Practice (courseId "interview", lessonId "q-cap") Link: https://crabrix.com/learn/interview/q-cap/ Goal: Specify the consistency model and failure protocol; quorum arithmetic alone is insufficient. Practice: open the starter in the Crabrix Playground (https://crabrix.com/playground/?lesson=interview/q-cap) and I will write the code there. Explain it step by step for my level, let me write the code myself, give hints before any solution, and do not mark anything as passed: only Crabrix checks do that.