Skip to content
StackDecode
System Design
6. Distributed Systems FundamentalsAnimated

CAP Theorem

During a partition, choose consistency or availability.

The idea

When the network splits, a system must either refuse some requests (consistent) or answer with possibly stale data (available).

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

Node 1Node 2Node 3Node 4Node 5
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Independent machines coordinate only by passing messages.

step:
1/4
at:
Node 1
1/8

The green dot is a request moving through the system.

Step by step

  1. 1Network partition happens
  2. 2CP: reject writes on the minority side
  3. 3AP: accept writes on both sides
  4. 4Reconcile after healing

Where it is used

Choosing database behaviour.

Watch out for

CAP is about partitions only. Day-to-day, latency vs consistency matters (PACELC).

Related