Academy · Consistency & Consensus

CAP & PACELC

When the network splits a distributed system in two, you can't have everything. What do you give up?

Open the interactive version → diagrams, practice & more

The problem

When the network splits a distributed system in two, you can't have everything. What do you give up?

The idea

CAP: during a partition you must choose Consistency or Availability (you can't keep both). PACELC adds: Else (no partition), choose Latency or Consistency.

How it works

CP systems refuse writes on the minority side to stay consistent (e.g. a strongly-consistent store). AP systems keep serving and reconcile later (eventual consistency). PACELC notes that even without partitions, stronger consistency costs latency.

The tradeoff

CP = correct but can be unavailable; AP = always up but can be stale/conflicting. Choose per data: money = CP, likes = AP.

In the wild

DynamoDB (AP-leaning, tunable), Spanner (CP with clever clocks), ZooKeeper (CP).

Interview deep dive

Flow

  1. Name the data that must stay correct during a partition.
  2. Choose CP when wrong answers are worse than rejected writes.
  3. Choose AP when stale answers are acceptable and uptime wins.
  4. Explain the normal-case PACELC latency cost too.

Watch for

Interviewer trap

Do not label the whole system CP or AP; label each critical data path.

Related Academy

Part of Academy on SystemLore — system design interview prep with 148 deep topics, interactive diagrams, and a practice game. Practice this one →