Course contentsShow
← Software Engineering
Lesson 1412 of 1,93341. Scalability and Distributed SystemsFree lesson

CAP in Real-World Systems

Analyzing how popular distributed systems like Cassandra, MongoDB, and etcd position themselves on the CAP spectrum.

CAP in Real-World Systems

What you'll learn: How popular distributed databases position themselves along the CAP spectrum and make explicit trade-offs for different use cases.

Theory Meets Practice

While the CAP theorem sounds absolute—"pick two"—real systems don't fit into neat boxes. Instead, modern distributed databases make nuanced trade-offs, often tunable by configuration, that position them at different points on the consistency-availability spectrum.

Real-World Examples

Cassandra (AP Focus)

Cassandra defaults to high availability and partition tolerance. During network partitions, it continues accepting writes to available nodes. You can tune consistency per-query using consistency levels (ONE, QUORUM, ALL), but its design philosophy favors staying online over strict consistency. Perfect for metrics, time-series data, or when brief inconsistency is acceptable.

MongoDB (CP Tunable)

MongoDB's default replica set behavior is CP—during partitions, minority nodes become unavailable for writes to preserve consistency. The primary (leader) must maintain contact with a majority to accept writes. However, MongoDB lets you trade consistency for availability through read preferences and write concerns, making it adaptable.

etcd (CP Strong)

Used by Kubernetes for cluster coordination, etcd is firmly CP. It uses Raft consensus to guarantee strong consistency. If a partition isolates the leader from the majority, writes fail rather than risk inconsistency. This is critical when coordinating distributed systems—wrong data is worse than waiting.

The Pattern

Notice the pattern: systems choose defaults based on their primary use case, but often expose tuning knobs. CP systems protect critical metadata; AP systems prioritize user-facing availability. PACELC helps explain their behavior even when partitions aren't happening—Cassandra accepts latency for availability (PA/EL), while etcd prioritizes consistency even during normal operation (PC/EC).

Key Takeaway: Real distributed systems don't strictly "pick two"—they position themselves strategically on the CAP spectrum based on use case priorities, often allowing operators to tune trade-offs per-operation.