CAP Theorem
Software Engineer path · lesson 55 of 99Visualize the trade-offs between Consistency and Availability when a Network Partition occurs in a distributed system.
CAP Theorem Demonstration
Node A State
Node B State
CP or AP during a partition?
Sort each behaviour or system by the choice it makes when the network splits.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
Chooses consistency (CP)
Drop items hereChooses availability (AP)
Drop items hereTest your knowledge
During a network partition, if a distributed database chooses to prioritize Availability (AP), what is the primary risk?
The short version
Imagine two receptionists (Node A & B) answering phones for the same company. If their internal intercom breaks (Partition), and a customer calls Node A to change their address, Node A must decide: Do I refuse the update until the intercom is fixed (Consistency), or do I take the update now, knowing Node B will give out the wrong address to the next caller (Availability)?
In more depth
The CAP Theorem
The CAP theorem states that any distributed data store can only provide two of the following three guarantees:
The Reality
Because network failures (Partitions) are inevitable in distributed systems, you must choose between Consistency and Availability when a partition occurs.
Interview Questions
References & Further Reading
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required