CAP Theorem: ATM Simulation

The CAP theorem is about three properties of a distributed system: Consistency (every read sees the latest write), Availability (every request gets an answer) and Partition tolerance (the system keeps working when the network splits). It is often summarised as "pick two of three", but that's misleading: network partitions are not optional. The real statement is narrower. When a partition happens, the system has to choose between consistency and availability.

This simulation uses an ATM network with a shared account to let you explore the trade-off hands-on. Withdraw money, cut a network link, and see what happens when the network heals.

How It Works

  1. Withdraw cash at any ATM - the backend confirms and every connected ATM sees the new balance
  2. Cut a link to isolate an ATM from the backend (a network partition)
  3. Choose a mode - Consistency (refuse what cannot be verified) or Availability (pay out up to an offline cap)
  4. Keep withdrawing at both the isolated and the connected ATMs
  5. Heal the partition to reconcile, and find out whether the account was overdrawn

Live simulation

All connected
Bank backend
Source of truth
$1,000account balance

What to try next

Withdraw cash at any ATM, then cut an ATM's link to create a network partition.

Setup

How much an isolated ATM may pay out in availability mode. Locked once a partition starts.

Event log

Key Takeaways

Further Reading

Decision Angle

In real systems, CAP trade-offs are architectural decisions. Teams should record when they choose consistency over availability, accept bounded staleness, allow offline operations with caps, or adopt specific reconciliation strategies. These are exactly the kinds of decisions that benefit from an Architecture Decision Record - they involve trade-offs, affect system behavior under failure, and are easy to forget once the system is running.

Next: The Lost EventDual writes, the transactional outbox, and why consumers must be idempotent.