← Back to Concepts

CAP Theorem

Understand the fundamental trade-offs between Consistency, Availability, and Partition tolerance

CAP Mode

Network

Write Data

Read Data

Try This:

  1. Write some data (e.g., "v1") with all nodes connected - both modes work perfectly
  2. Click Create Partition to simulate a network split
  3. In CP mode, try writing "v2" - it will fail to maintain consistency
  4. Switch to AP mode and write "v3" - it succeeds but only writes to the partitioned node
  5. Click Read Data to see inconsistent values across nodes in AP mode
  6. Click Heal Partition to restore the network and observe the results

Node Cluster

CONNECTED
💾
Node 1
Data: v0
💾
Node 2
Data: v0
💾
Node 3
Data: v0

Understanding CAP:

  • CP (Consistency + Partition tolerance): Rejects writes during partition to maintain consistency. Prioritizes correctness over availability.
  • AP (Availability + Partition tolerance): Accepts writes during partition but allows inconsistency. Prioritizes availability over consistency.
  • The Theorem: In a distributed system with network partitions, you must choose between Consistency and Availability.

Metrics

Total Writes
0
Successful
0
Failed
0
Inconsistent Reads
0