Home/Labs/CAP & PACELC Replicas
All 280 Labs
INTERACTIVE LAB🌐

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.

R1 (US-EAST)
value=cart-v1 · ts=1
R2 (US-WEST)
value=cart-v1 · ts=1
R3 (EU-WEST)
value=cart-v1 · ts=1
Empty cart replica set, 3 nodes, quorum/replication configured. Partition R3 (cut the cross-region link), then write and read from each side.
PACELC class
PA / EL — DynamoDB, Cassandra, CouchDB
Availability
0%
Divergence now / merges
no / 0
Stale reads served
0

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.
Interview Round Script

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.

Key Trade-Offs

AP keeps serving during partitions but leaks staleness and divergence; CP refuses operations but resolves the partition with a single truth.

Related Curriculum Chapter

NoSQL — Why & When (CAP & PACELC Trade-offs)

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs