Brewer Conjecture (CAP)
Brewer Conjecture (CAP)
Brewer Conjecture (CAP)
Examples
Databases, 2PC, centralized algo (C & A) Distributed databases, majority protocols (C & P) DNS, Bayou (A & P)
CAP theorem
Formalization by Gilbert & Lynch What does impossible mean?
There exist an execution which violates one of CAP not possible to guarantee that an algorithm has all three at all times
Shard data with different CAP tradeoffs Detect partitions and weaken consistency
WRITE(v)
READv
Quorum Principle
Majority Quorum
Pro: tolerate up to N/2 -1 crashes Con: Have to read/write N/2 +1 values
Maekwa Quorum
P1
P2 P5 P8
P3 P6 P9
Arrange nodes in a MxM grid P4 Write to row+col, read cols (always overlap) P7 Pro: Only need to read/write O( sqrt(N) ) nodes Con: Tolerate at most O( sqrt(N) ) crashes (reconfiguration)
Probabilistic Quorums
Quorum size N, ( > 1) intersects with probability 1-exp(2)
Example: Maekwa: N=16 nodes, quorum size 7, intersects 95%, tolerates 9 failures N=16 nodes, quorum size 7, intersects 100%, tolerates 4 failures
Pro: Small quorums, high fault-tolerance Con: Could fail to intersect, N usually large
8
Definition of Atomicity
Linearization Points Read ops appear as if immediately happened at all nodes at
time between invocation and response
P1
P2 P3 W(5)
R:6
R:5
W(6)
atomic
Definition of Atomicity
P1 P2 P3 P1 P2 P3 W(5) R:6 W(5) R:6 W(6) R:6
atomic
R:5
not atomic
W(6)
R:5
not atomic
W(5)
W(6)
R:5
R:6 not atomic sequentially consistent
W(5)
W(6)
Sequential consistency
Weaker than atomicity Sequential consistency removes this real-time requirement Any global ordering OK as long as they respect local ordering Does Gilberts proof fall apart for sequential consistency?
Causal memory
Weaker than sequential No need to have global view, each process different view Local, read/writes immediately return to caller CAP theorem does not apply to causal memory
P1
P2
Properties of gossipping
All nodes will have the same value in O(log N) time No positive-feedback cycles that congest the network
BASE
Catch all for any consistency model C that enables C-A-P
Eventual consistency PRAM consistency Causal consistency
Main ingredients
Stale data Soft-state (regenerateable state) Approximate answers
Summary
No need to ensure CAP at all times
Switch between algorithms or satisfy subset at different times
Weaken partition-tolerance
Some environments never partition, e.g. datacenters Tolerate unavailability in small quorums Some env. have recovery guarantees (partitions heal within X hours), perform conflict resolution