CAP-теорема и модели консистентности. CP vs AP под partition, session consistency, PACELC.
CAP is an impossibility result for a replicated read/write object. In the asynchronous model, while messages between partitions may be lost, no algorithm can guarantee both:
Partition tolerance is the failure condition being considered, not a product feature that can simply be exchanged for the other two. The choice becomes unavoidable during an execution in which the components cannot communicate.
Atomic or linearizable consistency means operations can be placed in a single order that respects real time. If a write completes before a read begins, that read cannot return an older value.
CAP availability is stronger than a typical monthly uptime SLO and weaker about latency: it requires termination but gives no finite response-time bound. A timeout or deliberate rejection therefore gives up this formal availability property even though it may be the correct product behavior.
The theorem does not say that every database is permanently “CP” or “AP”, nor that all consistency models form one switch. A system may make different decisions by operation, key, failure mode, or policy.
A consistency-preserving protocol may wait, reject, or route only to a component that can still prove a safe order. This preserves safety but some reachable clients do not receive successful results.
An availability-preserving protocol can accept independent operations on both sides. Because neither side can know the other side's concurrent history, it cannot promise one real-time atomic register. When communication returns, the application needs an explicit reconciliation rule: a commutative data type, domain merge, deterministic winner, or surfaced conflict. “Last timestamp wins” is not automatically safe when clocks and causality matter.
Conditions such as W + R > N describe overlap of selected read and write sets, but overlap by itself does not prove linearizability. A complete protocol must define leaders or version ordering, membership changes, failure detection, read repair, concurrent writers, and which acknowledgement makes an operation complete. Sloppy quorums and hinted replicas can intentionally choose nodes outside the original replica set.
A completed replicated write is ordered before a later read.
The write is not acknowledged because the protocol cannot prove a safe order across the cut.
Both components answer independently and later reconcile by a declared domain policy.
The animation separates the formal theorem from broader latency, durability and cost trade-offs.
Введите числа или выберите пресет