CAP & PACELC Replicas Lab (Interactive)
Sever the network, choose AP or CP, then heal the partition and repair diverged replicas. Partition a three-replica cluster, run reads and writes on each side in AP and CP modes, and quantify the availability, staleness, and silently lost concurrent writes you pay for.
CAP / PACELC Replica Trade-off Lab
Partition a 3-node store, then force it to choose: refuse service, or serve divergent data.
CAP covers only the partition moment; PACELC adds the ELSE clause: even when healthy, AP systems answer from one replica in 0.2 ms (Latency), while CP systems wait for a quorum round-trip (Consistency). Partitions are rare (≈0.01% of uptime) — the latency tax is paid every second, which is why the choice matters most in normal operation.
How It Works Under the Hood
CAP is not a menu of three options: when a network partition actually severs the cluster, the system must either reject operations touching the unreachable side (CP) or serve possibly stale data (AP). PACELC adds the everyday half: even with no partition, the Else clause trades latency (L) against consistency (C) — quorum reads pay cross-region round trips. After healing, AP clusters hold diverged copies; read-repair with last-write-wins deterministically discards one concurrent write. This lab makes you pull each of those consequences yourself.
Core Architectural Principles
- During a partition, CP clusters reject writes that cannot reach a quorum; AP clusters accept local writes and diverge.
- Else-latency: without any partition, strong consistency still costs synchronization round trips — the LC axis of PACELC.
- Healing an AP partition forces reconciliation: LWW read-repair silently drops the concurrent write on all but one replica.
In design interviews, state the partition-time choice per dataset: session caches can be AP, payment ledgers must be CP. Then show PACELC fluency by explaining that Cassandra and Dynamo choose low latency over consistency even without a partition — availability is not free on the normal path, and consistency is a quorum-latency dial.
AP keeps serving during partitions but leaks staleness and divergence; CP refuses operations but resolves the partition with a single truth.