How it works · 17 of 38 Advanced

What is the CAP theorem and eventual consistency?

Why two copies can disagree

Consistency & CAP: When copies of the same data sit on machines that can lose contact (a partition), each copy must choose, while cut off, between answering and risking an out-of-date answer (availability) or refusing until it can check (consistency); when the link works, a system can have both.

Loading the animation…

Say it like this When the link between two copies of your data breaks, each copy must either keep answering and risk saying something out of date, or refuse until it can check: that choice, not "pick two of three", is what CAP is about.

Under the hood — for builders
The source's own example: the ATM
Eric Brewer, who stated CAP: for an ATM "strong consistency would appear to be the logical choice, but in practice, A trumps C."
CAP in plain words
During a partition (parts that can't reach each other), choose: always answer (A) or always latest (C).
It costs even when nothing breaks
A strongly consistent read checks for the latest write. DynamoDB prices it at twice an eventually consistent one:
Across regions
DynamoDB global tables, default mode: changes reach other regions "typically within a second".
Eventual consistency
Copies may differ for a while, then agree. Fine for a feed; risky for a balance.
Watch out
DynamoDB indexes and streams can't do strongly consistent reads: a save-then-reload via an index may show the old value.
Sources
Brewer, "CAP Twelve Years Later" (2012, InfoQ) · DynamoDB Developer Guide, "DynamoDB read consistency" (read November 2026).

What happens in the consistency & CAP animation, step by step?

  1. Meera and Kabir share one bank account. A branch on each side of the river keeps its own copy, and a runner carries every change across the bridge. AWS's global tables copy a change typically within a second.
  2. Then the bridge goes down: a partition, the P in CAP. People say CAP means "pick any two of three", but links do break, so the real question is what each copy does when one does.
  3. Your turn: Meera in Mumbai and Kabir in Delhi each ask for ₹40,000 at the same moment. Each copy shows ₹50,000 and can't check the other. What should the machines do?
  4. Choose availability and both machines pay: ₹80,000 leaves a ₹50,000 account. When the bridge is back, the slips cross and both copies show −₹30,000.
  5. Choose consistency and both machines refuse: the balance stays right, but two customers walk away with nothing. While the link is down, neither choice is free.
  6. Real ATMs take a middle path: cut off, they pay only up to a small limit, and once the bridge is back both copies agree on ₹30,000. Next: every night the bank copies the day's transactions into a warehouse for reports. Clean them on the way in, or after?

What everyday example explains consistency & CAP?

One joint bank account with a ledger at a branch on each side of a river, and a runner who carries every change across the bridge. When the bridge is out, a branch can pay out without asking the other side, or turn customers away until the bridge is back.

Why should a team care about consistency & CAP?

For each operation, decide what a copy should do when it can't reach the others: show possibly stale data (feeds, catalogues, balance views), refuse (seat booking, money moving), or allow a bounded amount and reconcile later; then check that your database's read setting (eventual by default in DynamoDB) matches that choice.