CAP Theorem: ATM Simulation

The CAP theorem states that a distributed system can provide at most two of three guarantees simultaneously: Consistency, Availability, and Partition tolerance. Since network partitions are unavoidable in distributed systems, the practical choice is between consistency and availability during a partition.

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

How It Works

  1. Withdraw money from any ATM — the backend confirms and syncs the balance to all connected ATMs
  2. Click a connection line to simulate a network partition isolating that ATM
  3. Choose a mode — Consistency (reject withdrawals at partitioned ATMs) or Availability (allow offline withdrawals up to a cap)
  4. Attempt more withdrawals at both connected and partitioned ATMs to see the behavior
  5. Heal the partition to trigger reconciliation and see if overdrafts occurred

Simulation

$1,000
ATM
ATM 1
$1,000
ATM
ATM 2
$1,000
🏦
Bank Backend
ATM
ATM 3
$1,000

Event Timeline

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.