Базы данных. CAP

  • View
    679

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Text of Базы данных. CAP

  • 1. Consistency, Availability and Partition Tolerance http://incubos.org @incubos Computer Science Center 16 2013 . . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 1 / 27
  • 2. 1 Remembrance Inc. 2 CAP theorem 3 4 . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 2 / 27
  • 3. Remembrance Inc. Never forget, even without remembering!a a http: //ksat.me/a-plain-english-introduction-to-cap-theorem/ Ever felt bad that you forget so much? Dont worry. Help is just a phone away! When you need to remember something, just call 555-55-REMEM and tell us what you need to remember. For eg., call us and let us know of your bosss phone number and forget to remember it. When you need to know it back, call back the same number 555-55-REMEM and well tell you whats your bosss phone number. Charges: only $0.1 per request . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 3 / 27
  • 4. Remembrance Inc. Customer : Hey, can you store my neighbors birthday? You: Sure... When is it? Customer : 2nd of Jan You: (write it down against the customers page in your paper note book) Stored. Call us any time for knowing your neighbors birthday again! Customer : Thank you! You: No problem! We charged your credit card with $0.1 . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 4 / 27
  • 5. Remembrance Inc. YCombinator . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 5 / 27
  • 6. Remembrance Inc. 55555-REMEM . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 6 / 27
  • 7. Remembrance Inc. Customer : Hey! You: Glad you called Remembrance Inc!. What can I do for you? Customer : Can you tell me when is my ight to New Delhi? You: Sure... 1 sec, sir. (You look up your notebook. WOW! There is no entry for "ight date"in customers page!!!) You: Sir, I think there is a mistake. You never told us about your ight to Delhi. Customer : What?! I just called you guys yesterday! (Cuts the call!) . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 7 / 27
  • 8. Remembrance Inc. -, , , , - . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 8 / 27
  • 9. Remembrance Inc. Consistent & Available Consistent & Available : email . . (CompSciCenter) Consistency, Availability and Partition Tolerance 16 2013 . 9 / 27
  • 10. Remembrance Inc. Partition Tolerance Partition Tolerance , - , partition tolerance, , availability . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 10 / 27
  • 11. CAP theorem CAP theorem E. Brewer. Towards Robust Distributed Systems, 2000. 2 3: Consistency Availability Partition Tolerance . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 11 / 27
  • 12. CAP theorem 1 : C, A P P in a distributed system is a MUST HAVE C/A C/A , , , . . , 1 http://www.infoq.com/articles/ cap-twelve-years-later-how-the-rules-have-changed . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 12 / 27
  • 13. CAP theorem Latency Latency CAP : = = = = . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 13 / 27
  • 14. CAP theorem false positives / Yahoo PNUTS: per user + Facebook2 : , 20 , 2 http: //www.facebook.com/note.php?note_id=23844338919&id=9445547199 . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 14 / 27
  • 15. CAP theorem . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 15 / 27
  • 16. CAP theorem , , HTML5 on-client persistent storage (primary partition, quorum) . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 16 / 27
  • 17. CAP theorem ( ) , ( . DVCS) Commutative Replicated Data Types (CRDTs)34 3 M. Shapiro et al. Conict-Free Replicated Data Types. 2011 M. Shapiro et al. Convergent and Commutative Replicated Data Types. 2011 4 . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 17 / 27
  • 18. CAP theorem : ATM : ATM : 0 availability , , overdraft . Check kiting5 5 http://en.wikipedia.org/wiki/Check_kiting . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 18 / 27
  • 19. CAP theorem Use Case: Ebay Use Case: Ebay Principles for Scaling6 : Partition Everything Vertical, horizontal, no session state Asynchrony Everywhere Events, multicast Automate Everything Adaptive conguration, machine learning Remember Everything Fails Failure detection, rollback, graceful degradation Embrace Inconsistency Eventual consistency, no distributed transactions 6 Randy Shoup at LADIS 2008, http://www.cs.cornell.edu/projects/ ladis2008/materials/eBayScalingOdyssey%20ShoupTravostino.pdf . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 19 / 27
  • 20. A unit of work performed against a database, and treated in a coherent and reliable way independent of other transactionsa a http://en.wikipedia.org/wiki/Database_transaction : ACID7 focus on consistency BASE focus on high availability 7 Name was coined (no surprise) in California in 60s . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 20 / 27
  • 21. ACID- ACID- Atomicity , commit/rollback, undo-log, , ... Consistency , , , , , ... Isolation : Read uncommitted / dirty reads, Read committed / non-repeatable read, Repeatable reads / phantom reads, Serializable, MVCC8 , ... Durability 8 http: //en.wikipedia.org/wiki/Multiversion_concurrency_control . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 21 / 27
  • 22. commit commit Two-phase commit protocol9 Three-phase commit protocol10 Paxos11 , 9 http://en.wikipedia.org/wiki/2PC http://en.wikipedia.org/wiki/3PC 11 http://en.wikipedia.org/wiki/Paxos_(computer_science) 10 . . (CompSciCenter) Consistency, Availability and Partition Tolerance 6 2013 . 1 22 / 27
  • 23. ACID in CAP ACID in CAP Atomicity Consistency Isolation , Durability Durable history - . . (CompSciCenter) Consistency, Ava