Availability Prioritized (AP) vs Consistency Prioritized (CP) Wide-Column Systems
Availability Prioritized Systems
AP (Availability Prioritized) systems remain available during network partitions by letting any replica accept writes independently. Reads and writes use tunable consistency levels per operation. With replication factor 3 (data copied to 3 nodes), setting both read and write to QUORUM (majority, so 2 of 3) ensures immediate consistency since 2 + 2 > 3. LOCAL_QUORUM limits acknowledgment to the local datacenter, giving 5-10ms latency while surviving datacenter failures.
The tradeoff: no multi-row transactions. Concurrent writes to the same key resolve via "last write wins" using timestamps, requiring tight NTP (Network Time Protocol) synchronization. Clock skew beyond 100ms can cause updates to appear out of order, losing data.
Consistency Prioritized Systems
CP (Consistency Prioritized) systems route all writes for a region to a single leader that serializes operations. This provides linearizable reads (always see latest write) and strong per-row consistency. If the leader becomes unreachable, writes stall until a new leader is elected, sacrificing availability for correctness.
Leader election requires coordination, often using a consensus system like ZooKeeper (a coordination service maintaining configuration and detecting failures). Failover takes 30-120 seconds: heartbeat timeout (30s), master reassigns region (10-60s), and WAL (Write-Ahead Log) replay from distributed storage (5-30s).
When to Choose Each Model
Choose AP when always-on operation matters more than per-row linearizability. Activity feeds, metrics, and session stores tolerate eventual consistency. Multi-datacenter deployments handle trillions of operations daily at sub-20ms p99 with LOCAL_QUORUM.
Choose CP when per-row correctness is paramount: message ordering in an inbox, counter semantics, or inventory decrements. CP systems integrate well with batch analytics via HDFS (Hadoop Distributed File System), though they accept unavailability during leader transitions.