CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

12
CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013

Transcript of CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

Page 1: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

CAP Theorem

Justin DeBrabant

Page 2: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Properties of Distributed Systems

• Consistency – all nodes have up-to-date view of data

• Availability – every request receives a response

• Partition Tolerance– system will continue to function if partitions are

isolated from each other• Question: Is there a tradeoff here?

Page 3: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

ACID• Atomicity – all or nothing

• Consistency – data is always in a valid state

• Isolation – concurrently executing transactions are isolated

• Durability – once committed, changes made by transaction are

permanent

Page 4: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

BASE

• Basically Available Soft-state Eventual Consistency – Forfeits the “C” and “I” of ACID in return for

availability – most NoSQL systems provide BASE instead of ACID

guarantees

Page 5: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

ACID vs. BASE

• ACID– Focuses on consistency and isolation

• BASE– weak consistency • data can be stale

– availability first– simpler implementation– faster• is this always true?

Page 6: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

CAP Theorem

• “At most two.”– you can have at most two of the CAP properties

for any shared data system• Disclaimer: – some question the assumptions used to prove the

“theorem”– thoughts?

Page 7: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Page 8: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Consistency + Availability

• Give up partitions • Characteristics – two-phase commit– cache validation protocols

• Example– single-site databases

Page 9: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Consistency + Partitions

• Give up availability • Characteristics – pessimistic locking

• Example– distributed databases

Page 10: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Availability + Partitions

• Give up consistency • Characteristics – optimistic concurrency control– conflict resolution protocols

• Example– web caching– DNS– NoSQL systems

Page 11: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Take-Homes• In real-world systems, there are (probably)

tradeoffs• Which do you tradeoff? – depends on…

• workload• data• users

– requires a deep understanding of the choices available • In reality, systems all along this spectrum are

useful in different ways

Page 12: CAP Theorem Justin DeBrabant CIS 570 - Advanced Systems - Fall 2013.

CIS 570 - Advanced Systems - Fall 2013

Questions?