senior loop
Deep Dives/Consistency & CAP

Consistency & CAP

CAP is quoted more than it is understood. The useful version is a per-feature answer to one question: when machines cannot talk, do you refuse the request or serve possibly-wrong data?

FundamentalsDistributed Systems~12 min · 5 sections

Prerequisites: Replication basics and the fact that networks drop messages.

Cover these firstReplication & Partitioning

After this: State a consistency requirement precisely instead of reaching for 'eventually consistent'.

Suggested first pass: Read sections 1–5, answer each section in your own words, then use the remaining failure modes and exercises as the advanced pass.

The usual phrasing, "pick two of consistency, availability, partition tolerance", is misleading, because you do not pick partition tolerance. Networks drop packets, links fail, machines become unreachable. Data on more than one machine will be partitioned sooner or later.

So the real statement: when a partition occurs, choose between consistency and availability. Two nodes cannot reach each other, a write arrives at one of them, and there are exactly two options.

  • CP. Refuse the write, because you cannot confirm the other side agrees. Correct, and unavailable for that request.
  • AP. Accept it here and reconcile later. Still serving, and the two sides temporarily disagree.

The choice applies only during a partition. The rest of the time you can have both.

PACELC, the half you live with daily

If Partitioned, choose Availability or Consistency; Else, choose Latency or Consistency. Even on a perfect network, confirming a write across replicas costs time, so every system trades some latency for some freshness. That second clause describes normal operation, which is most of the time, and it is the better mental model.

Next deep dive
Failures, Timeouts & Retries
~12 min