LESSON 02 · CAP

State CAP honestly

CAP describes one narrow choice: when replicas cannot talk, a node must either refuse a request or risk a stale answer.

SYSTEM VIEW

The agreement path

Diagram view
Stored on—
Seat 14—
Write waits—

Watch three regions sell seats through one store that needs a majority, then cut one region off and see what it can still do.

  1. Regions A, B and C run one store that commits a purchase once a majority, 2 of 3, has stored it. A buyer takes seat 9 through A, and once B has stored it too, it commits. C’s copy follows. While the network is healthy, answers are both current and available.

    Regions
    A, B, C
    Commit needs
    2 of 3

    What changed

    • Seat 9 sold through A
    • Stored on A and B: committed
  2. At 14:00 the links between region C and the others fail. C keeps running and its buyers still reach it, but nothing crosses to A or B. No design opts out of partitions; the choice is what a cut-off node does.

    Cut off
    C, at 14:00
    C can reach
    1 of 3: itself

    What changed

    • Links from C to A and B
    • C still running
  3. A and B are two of three, so they keep selling and their buyers notice nothing. A buyer takes seat 14 through A: B stores it and the sale commits, but the copy sent to C is lost, so C’s copy still shows seat 14 free.

    Majority
    A and B
    Seat 14
    sold through A

    What changed

    • Seat 14 sold through A
    • C’s copy still says free
  4. A buyer at C asks for seat 14. C can’t reach a majority, so it refuses and answers stay linearizable. C’s buyers see errors until traffic moves: the store gives up CAP’s availability, though most buyers are served. Try Sell anyway: C stays available, but two buyers own seat 14 and someone must refund and apologize.

    CAP’s consistency
    linearizable
    CAP’s availability
    every node answers

    What changed

    • Purchase of seat 14 at C
    • C can’t reach a majority
    Region C
  5. The choice need not be global. C keeps refusing purchases but still serves its seat map, slightly stale: it shows seat 14 free though A sold it. Cassandra exposes this per query through consistency levels such as ONE and QUORUM.

    Purchases at C
    refused
    Seat map at C
    may be stale
    Cassandra
    ONE or QUORUM

    What changed

    • Purchases at C refused
    • Seat map served from C
  6. The links return, and an everyday trade remains. With an example 80 ms round trip, a synchronous write waits about 80 ms for B. Try Asynchronous: A answers in a few ms, but a sale only A holds is lost if A fails. PACELC adds this trade; CAP doesn’t.

    Round trip
    80 ms (example)
    Framing
    PACELC

    What changed

    • Links to C restored
    • A write waits, or risks a loss
    Write

Space plays · ← → step · Home resets

THE IDEA

How it works

CAP is often summarized as “pick two of consistency, availability, and partition tolerance.” That wording misleads, because you cannot opt out of partitions: cables get cut, switches fail, and processes stall long enough to look gone. The real statement is narrower. While a partition lasts, a node that cannot reach its peers can refuse the request, keeping answers linearizable, or answer anyway, staying available but perhaps stale. When the network is healthy, you can have both.

The terms are narrow too. Consistency here means linearizability only. Availability means every working node answers every request, which majority-based systems give up even though most clients keep working. Take three regions running one such store, with region C cut off at 14:00. A and B still form a majority and keep selling seats. A purchase reaching C is refused, so buyers routed there see errors until traffic moves. Had C sold on its own, two buyers could own seat 14, and someone would have to refund and apologize.

The choice need not be global. An app can refuse purchases during a partition and still serve a slightly stale seat map. Cassandra exposes this per query through consistency levels such as ONE and QUORUM.

Partitions are rare, and a daily tradeoff is easier to miss. With an example round trip of 80 ms between regions, a synchronous write pays about 80 ms, while an asynchronous one returns in a few milliseconds but can lose recent data if that region fails. CAP does not describe this tradeoff; the PACELC framing adds it.

DECISION POINT

Your ticketing site runs in two regions, and the link between them may fail during a sale. You can stop selling in the region that loses contact with the leader, or give each region its own reserved block of seats in advance. Which do you choose?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • You cannot opt out of partitions; you choose what a cut-off node does.
  • CAP’s consistency means linearizability, and its availability is stricter than everyday uptime.
  • Without a partition, the everyday tradeoff is latency against freshness.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

A cut isolates region C from regions A and B. Their store requires a majority for each write. A purchase reaches region C. What happens?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.