CAP Theorem. March 26, Thanks to Arvind K., Dong W., and Mihir N. for slides.

Similar documents
Consistency in Distributed Storage Systems. Mihir Nanavati March 4 th, 2016

NoSQL systems: sharding, replication and consistency. Riccardo Torlone Università Roma Tre

CS6450: Distributed Systems Lecture 11. Ryan Stutsman

Report to Brewer s original presentation of his CAP Theorem at the Symposium on Principles of Distributed Computing (PODC) 2000

Strong Consistency & CAP Theorem

CS6450: Distributed Systems Lecture 15. Ryan Stutsman

SCALABLE CONSISTENCY AND TRANSACTION MODELS

10. Replication. Motivation

Final Exam Logistics. CS 133: Databases. Goals for Today. Some References Used. Final exam take-home. Same resources as midterm

Computing Parable. The Archery Teacher. Courtesy: S. Keshav, U. Waterloo. Computer Science. Lecture 16, page 1

Distributed Hash Tables

The CAP theorem. The bad, the good and the ugly. Michael Pfeiffer Advanced Networking Technologies FG Telematik/Rechnernetze TU Ilmenau

Large-Scale Key-Value Stores Eventual Consistency Marco Serafini

CONSISTENT FOCUS. Building reliable distributed systems at a worldwide scale demands trade-offs between consistency and availability.

Consistency. CS 475, Spring 2018 Concurrent & Distributed Systems

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Eventual Consistency 1

Replication in Distributed Systems

Database Availability and Integrity in NoSQL. Fahri Firdausillah [M ]

Recap. CSE 486/586 Distributed Systems Case Study: Amazon Dynamo. Amazon Dynamo. Amazon Dynamo. Necessary Pieces? Overview of Key Design Techniques

Transactions and ACID

CS /15/16. Paul Krzyzanowski 1. Question 1. Distributed Systems 2016 Exam 2 Review. Question 3. Question 2. Question 5.

DrRobert N. M. Watson

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Self-healing Data Step by Step

Recap. CSE 486/586 Distributed Systems Case Study: Amazon Dynamo. Amazon Dynamo. Amazon Dynamo. Necessary Pieces? Overview of Key Design Techniques

CMU SCS CMU SCS Who: What: When: Where: Why: CMU SCS

Goal of the presentation is to give an introduction of NoSQL databases, why they are there.

Introduction to Computer Science. William Hsu Department of Computer Science and Engineering National Taiwan Ocean University

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

Architekturen für die Cloud

10.0 Towards the Cloud

Extreme Computing. NoSQL.

CS5412: ANATOMY OF A CLOUD

Topics in Reliable Distributed Systems

Data Consistency Now and Then

Distributed Systems. Day 13: Distributed Transaction. To Be or Not to Be Distributed.. Transactions

Eventual Consistency Today: Limitations, Extensions and Beyond

EECS 498 Introduction to Distributed Systems

CSE 544 Principles of Database Management Systems. Alvin Cheung Fall 2015 Lecture 14 Distributed Transactions

CompSci 516 Database Systems

Dynamo: Amazon s Highly Available Key-value Store. ID2210-VT13 Slides by Tallat M. Shafaat

11. Replication. Motivation

Big Data Management and NoSQL Databases

NoSQL Databases. Vincent Leroy

Replications and Consensus

SCALABLE CONSISTENCY AND TRANSACTION MODELS THANKS TO M. GROSSNIKLAUS

Dynamo: Key-Value Cloud Storage

Data-Intensive Distributed Computing

Important Lessons. Today's Lecture. Two Views of Distributed Systems

CISC 7610 Lecture 2b The beginnings of NoSQL

Modern Database Concepts

Consistency: Relaxed. SWE 622, Spring 2017 Distributed Software Engineering

Last time. Distributed systems Lecture 6: Elections, distributed transactions, and replication. DrRobert N. M. Watson

Introduction to NoSQL

Eventual Consistency Today: Limitations, Extensions and Beyond

CS October 2017

Introduction Aggregate data model Distribution Models Consistency Map-Reduce Types of NoSQL Databases

CS Amazon Dynamo

Apache Cassandra - A Decentralized Structured Storage System

Replication. Feb 10, 2016 CPSC 416

Lecture 6 Consistency and Replication

Performance and Forgiveness. June 23, 2008 Margo Seltzer Harvard University School of Engineering and Applied Sciences

NoSQL Concepts, Techniques & Systems Part 1. Valentina Ivanova IDA, Linköping University

DISTRIBUTED COMPUTER SYSTEMS

NOSQL EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY

Distributed Consensus: Making Impossible Possible

Distributed Key Value Store Utilizing CRDT to Guarantee Eventual Consistency

Mutual consistency, what for? Replication. Data replication, consistency models & protocols. Difficulties. Execution Model.

Distributed Systems. Characteristics of Distributed Systems. Lecture Notes 1 Basic Concepts. Operating Systems. Anand Tripathi

Distributed Systems. Characteristics of Distributed Systems. Characteristics of Distributed Systems. Goals in Distributed System Designs

Overview. * Some History. * What is NoSQL? * Why NoSQL? * RDBMS vs NoSQL. * NoSQL Taxonomy. *TowardsNewSQL

4/9/2018 Week 13-A Sangmi Lee Pallickara. CS435 Introduction to Big Data Spring 2018 Colorado State University. FAQs. Architecture of GFS

Distributed Systems. replication Johan Montelius ID2201. Distributed Systems ID2201

Advances in Data Management - NoSQL, NewSQL and Big Data A.Poulovassilis

Exam 2 Review. October 29, Paul Krzyzanowski 1

Riak. Distributed, replicated, highly available

The NoSQL movement. CouchDB as an example

Horizontal or vertical scalability? Horizontal scaling is challenging. Today. Scaling Out Key-Value Storage

Consistency and Replication 1/62

CIB Session 12th NoSQL Databases Structures

CISC 7610 Lecture 5 Distributed multimedia databases. Topics: Scaling up vs out Replication Partitioning CAP Theorem NoSQL NewSQL

Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services

Relational databases

Two phase commit protocol. Two phase commit protocol. Recall: Linearizability (Strong Consistency) Consensus

Distributed Data Store

FIT: A Distributed Database Performance Tradeoff. Faleiro and Abadi CS590-BDS Thamir Qadah

Distributed Data Management Summer Semester 2015 TU Kaiserslautern

CAP Theorem, BASE & DynamoDB

Distributed Systems. Lec 10: Distributed File Systems GFS. Slide acks: Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung

Parallel Data Types of Parallelism Replication (Multiple copies of the same data) Better throughput for read-only computations Data safety Partitionin

CS 470 Spring Fault Tolerance. Mike Lam, Professor. Content taken from the following:

CA485 Ray Walshe NoSQL

CAP and the Architectural Consequences

CMPT 354: Database System I. Lecture 11. Transaction Management

CSE 530A. Non-Relational Databases. Washington University Fall 2013

Synchronization. Chapter 5

WHERE TO PUT DATA. or What are we going to do with all this stuff?

CS 655 Advanced Topics in Distributed Systems

Scaling Out Key-Value Storage

Transcription:

C A CAP Theorem P March 26, 2018 Thanks to Arvind K., Dong W., and Mihir N. for slides.

CAP Theorem It is impossible for a web service to provide these three guarantees at the same time (pick 2 of 3): (Sequential) Consistency Availability Partition-tolerance Conjectured by Eric Brewer in 00 Proved by Gilbert and Lynch in 02 But with definitions that do not match what you d assume (or Brewer meant) Influenced the NoSQL mania Highly controversial: the CAP theorem encourages engineers to make awful decisions. Stonebraker Many misinterpretations

CAP Theorem Consistency: Sequential consistency (a data item behaves as if there is one copy) Availability: Node failures do not prevent survivors from continuing to operate Partition-tolerance: The system continues to operate despite network partitions CAP says that A distributed system can satisfy any two of these guarantees at the same time but not all three

C in CAP!= C in ACID They are different! CAP s C(onsistency) = sequential consistency Similar to ACID s A(tomicity) = Visibility to all future operations ACID s C(onsistency) = Does the data satisfy schema constraints

Sequential consistency Makes it appear as if there is one copy of the object Strict ordering on ops from same client A single linear ordering across client ops If client a executes operations {a1, a2, a3,...}, client b executes operations {b1, b2, b3,...} Then, globally, clients observe some serialized version of the sequence e.g., {a1, b1, b2, a2,...} (or whatever)

CAP Theorem: Proof A simple proof using two nodes: A B Partition Client A

CAP Theorem: Proof A simple proof using two nodes: Not Consistent! A B Respond to client Client B Partition Client A

CAP Theorem: Proof A simple proof using two nodes: Not Available! A B Wait to be updated Partition Client B Client A

CAP Theorem: Proof A simple proof using two nodes: A gets updated from B A B Not Partition Tolerant! Client B Client A

CAP Misinterpretations Of the following three guarantees potentially offered by distributed systems: Consistency Availability Partition tolerance C A Pick two This suggests there are three kinds of distributed systems: CP AP CA P

Issues with CAP What does it mean to choose or not choose partition tolerance? P is a property of the environment, C and A are goals In other words, what's the difference between a "CA" and "CP" system? both give up availability on a partition! Better phrasing: if the network can have partitions, do we give up on consistency or availability?

Witnesses: P is unavoidable Coda Hale, Yammer (Microsoft?) software engineer: Of the CAP theorem s Consistency, Availability, and Partition Tolerance, Partition Tolerance is mandatory in distributed systems. You cannot not choose it. http://codahale.com/you-cant-sacrifice-partition-tolerance/

Witnesses: P is unavoidable Werner Vogels, Amazon CTO An important observation is that in larger distributed-scale systems, network partitions are a given; therefore, consistency and availability cannot be achieved at the same time. http://www.allthingsdistributed.com/2008/12/eventually_consistent.html

Witnesses: P is unavoidable Daneil Abadi (UMD), Co-founder of Hadapt; Vertica, VoltDB contributor So in reality, there are only two types of systems... I.e., if there is a partition, does the system give up availability or consistency? http://dbmsmusings.blogspot.com/2010/04/problems-with-cap-and-yahoos-little.html

Witnesses: P? Who cares about P!? Michael Stonebraker [VoltDB, TuringAward 14] In my experience, network partitions do not happen often. Specifically, they occur less frequently than the sum of bohrbugs [deterministic DB crashes], application errors, human errors and reprovisioning events. So it doesn t much matter what you do when confronted with network partitions. Surviving them will not move the needle on availability because higher frequency events will cause global outages. Hence, you are giving up something (consistency) and getting nothing in return. https://www.voltdb.com/blog/2010/10/21/clarifications-cap-theorem-data-related-errors/

CAP Theorem 12 year later Eric Brewer: father of CAP The 2 of 3 formulation was always misleading because it tended to oversimplify the tensions among properties.... CAP prohibits only a tiny part of the design space: perfect availability and consistency in the presence of partitions, which are rare. http://www.infoq.com/articles/cap-twelve-years-later-how-the-rules-have-changed

Consistency or Availability Consistency and Availability is not a binary decision AP systems relax consistency in favor of availability but are not inconsistent C A CP systems sacrifice availability for consistencybut are not unavailable P This suggests both AP and CP systems can offer a degree of consistency, and availability, as well as partition tolerance

AP: Best Effort Consistency Example: CDNs / Web caches DNS BlockChain CRDTs Trait: Optimistic concurrency control Expiration/Time-to-live Conflict resolution

CP: Best Effort Availability Example: Majority protocols (Paxos, Raft) Distributed Locking (Google Chubby Lock service) Trait: Pessimistic locking Make minority partition unavailable

Types of Consistency Strong Consistency After the update completes, any subsequent access will return the same updated value. Weak Consistency It is not guaranteed that subsequent accesses will return the updated value. Eventual Consistency Specific form of weak consistency It is guaranteed that if no new updates are made to object, eventually all accesses will return the last updated value (e.g., propagate updates to replicas in a lazy fashion)

Eventual Consistency Variations Causal consistency Processes that have causal relationship will see consistent data Read-your-write consistency A process always accesses the data item after it s update operation and never sees an older value Session consistency As long as session exists, system guarantees readyour-write consistency Guarantees do not overlap sessions

Eventual Consistency Variations Monotonic read consistency If a process has seen a particular value of data item, any subsequent processes will never return any previous values Monotonic write consistency The system guarantees to serialize the writes by the same process In practice A number of these properties can be combined Monotonic reads and read-your-writes are most desirable

Eventual Consistency - A Facebook Example Bob finds an interesting story and shares with Alice by posting on her Facebook wall Bob asks Alice to check it out Alice logs in her account, checks her Facebook wall but finds: - Nothing is there!

Eventual Consistency - A Facebook Example Bob tells Alice to wait a bit and check out later Alice waits for a minute or so and checks back: - She finds the Cambridge Analytica story Bob shared with her!

Eventual Consistency - A Facebook Example Reason: it is possible because Facebook uses an eventual consistent model Why would Facebook choose an eventual consistent model over the strong consistent one? Facebook has more than 1 billion active users It is non-trivial to efficiently and reliably store the huge amount of data generated at any given time Eventual consistent model offers the option to reduce the load and improve availability

Dynamic Tradeoff between C and A An airline reservation system: When most of seats are available: it is ok to rely on somewhat out-of-date data, availability is more critical When the plane is close to be filled: it needs more accurate data to ensure the plane is not overbooked, consistency is more critical Neither strong consistency nor guaranteed availability, but it may significantly increase the tolerance of network disruption

Heterogeneity: Segmenting C and A No single uniform requirement Some aspects require strong consistency Others require high availability Segment the system into different components Each provides different types of guarantees Overall guarantees neither consistency nor availability Each part of the service gets exactly what it needs Can be partitioned along different dimensions

Partitioning Strategies Data Partitioning Operational Partitioning Functional Partitioning User Partitioning Hierarchical Partitioning Idea: provide differentiated guarantees depending on X {data/op/func/user/component}

Partitioning Examples Data Partitioning Different data may require different consistency and availability Example: Shopping cart: high availability, responsive, can sometimes suffer anomalies Product information need to be available, slight variation in inventory is sufferable Checkout, billing, shipping records must be consistent

Partitioning Examples Operational Partitioning Each operation may require different balance between consistency and availability Example: Reads: high availability; e.g.., query Writes: high consistency, lock when writing; e.g., purchase

Partitioning Examples Functional Partitioning System consists of sub-services Different sub-services provide different balances Example: A comprehensive distributed system Distributed lock service (e.g., Chubby) : Strong consistency DNS service: High availability

Partitioning Examples User Partitioning Try to keep related data close together to assure better performance Example: Craigslist Might want to divide its service into several data centers, e.g., east coast and west coast Users get high performance (e.g., high availability and good consistency) if they query servers close to them Poorer performance if a New York user query Craglist in San Francisco

Partitioning Examples Hierarchical (node) Partitioning Large global service with local extensions Different location in hierarchy may use different consistency Example: Local servers (better connected) guarantee more consistency and availability Global servers has more partition and relax one of the requirement

Take-aways CAP is a tool for thinking about trade-offs in distributed systems Misinterpreted + contentious The devil (in designing distributed systems) is often in the details: real systems cannot be classified into one of CA/AP/CP Many eventual consistency variants, widely adopted by popular systems