Core Concept

CAP Theorem & Consistency Models

During a network partition, you must trade off immediate data consistency (CP) for write availability (AP); it is a physical law of distributed networks.


What:

The CAP Theorem states that in a distributed system, during a network partition, you can guarantee Consistency (CP) OR Availability (AP), but not both.

Primary purpose:

Guiding trade-offs around database scaling, distributed locking, and partition resilience during network splits.

Usually used for:

Designing microservices state stores, selecting distributed datastores, and defining consistency SLAs.

How should I think about this inside system architectures?

⚡ PACELC Extension

CAP only applies when there is a partition (P). Else (E), you must balance Latency (L) against Consistency (C).

🤝 Quorum overlap

Tune consistency dynamically: if your read node pool overlaps your write pool (R + W > N), you read the latest value.

🕰️ Vector Clock Timestamps

In eventual AP networks, use logical vector clocks to trace dependencies and resolve concurrent write conflicts.