CAP & consistency
Two regions hold copies of one balance. Cut the link between them, then see which choice refuses writes, which answers with old data, and what is lost when the link comes back.
Two regions each hold a copy of one balance. When the link between them breaks, called a partition, each region must choose.
- CP: refuse writes until the link is back. Both copies stay the same, and users see errors.
- AP: keep taking writes on both sides. Users see no errors, but the copies differ. When the link heals, one side's writes can be lost.
- Read-Your-Writes is not a third CAP choice. It runs on top of AP, and sends your reads to the region that holds your own last write.
Step through one partition
Two regions hold one balance of $100. The link between them breaks, two users each make a deposit, and User 1 checks their balance. Pick a choice, then press Next step. Back takes you to the step before.
With this choice: Both deposits were taken, but User 1 read $120 without their own deposit. When the link came back, last-writer-wins kept $120 and lost the $50.
- User 1 — near US-East — healthy
- User 2 — near EU-West — healthy
- US-East — user:balance — healthy — NOW — cut off
- EU-West — user:balance — healthy — cut off
- Copy between regions
- Deposit
- Answer
Step 1 of 5 · US-East
Failed: The link between the regions breaks
- What happens
- Both regions still run and still hold $100, but they cannot reach each other.
- Why
- This is a partition: the network splits, and each side keeps working alone.
- What changes
- Each region must now choose what to do with writes.
- Next
- US-East takes User 1's $50 deposit
Event log
4 more to go. Press a line to go back to that step.
Step 1 of 5: US-East. The link between the regions breaks. Both regions still run and still hold $100, but they cannot reach each other.
What this simplifies. This run uses two regions, one key and a stated order of events. Real systems often use three or more sites, so a majority can keep taking writes. Many also merge both changes instead of dropping one.
Try it yourself
Press "Trigger Network Partition", make deposits in both regions, then press "Read my balance" and heal the link.
You made the deposits above. Your next read goes to the other region, as if your phone switched networks.