CAP Theorem

CAP Theorem

A basic overview of the problems facing distributed systems for Hackbright Girl Geek Dinner

248ff8e8c560fbd557fd1c52634a0543?s=128

Liz Howard

August 21, 2013
Tweet

Transcript

  1. I’m @lizTheDeveloper Director of Operations Instructor / Developer @Hackbright Academy

    Wednesday, August 21, 13
  2. CAP Theorem Wednesday, August 21, 13

  3. What is CAP Theorem? Wednesday, August 21, 13

  4. What is CAP Theorem? Comes into play when we start

    to want to replicate databases Wednesday, August 21, 13
  5. What is CAP Theorem? Consistency Wednesday, August 21, 13

  6. What is CAP Theorem? Consistency Database behaves as though we

    have a single, constantly up-to-date copy of the data Wednesday, August 21, 13
  7. What is CAP Theorem? Availability Wednesday, August 21, 13

  8. What is CAP Theorem? Availability We can always read and

    write that data Wednesday, August 21, 13
  9. What is CAP Theorem? Tolerance to Network Partitions Wednesday, August

    21, 13
  10. What is CAP Theorem? Tolerance to Network Partitions What happens

    when part of the database isn’t accessible? Wednesday, August 21, 13
  11. What is CAP Theorem? Tolerance to Network Partitions What happens

    when part of the database isn’t accessible? Partitions are inevitable Wednesday, August 21, 13
  12. Why is CAP Theorem important? Wednesday, August 21, 13

  13. Why is CAP Theorem important? Understanding how distributed systems work

    Wednesday, August 21, 13
  14. Why is CAP Theorem important? Understanding how distributed systems work

    How to make things work at scale Wednesday, August 21, 13
  15. Why is CAP Theorem important? Understanding how distributed systems work

    How to make things work at scale Knowing what limits exist, and why Wednesday, August 21, 13
  16. ACID Compliance Wednesday, August 21, 13

  17. ACID Atomicity : A group of transactions that succeed completely

    or fail completely Wednesday, August 21, 13
  18. ACID Atomicity : A group of transactions that succeed completely

    or fail completely Example: Booking a flight Wednesday, August 21, 13
  19. ACID Atomicity : A group of transactions that succeed completely

    or fail completely Example: Booking a flight Reserve a seat and collect money XOR Wednesday, August 21, 13
  20. ACID Atomicity : A group of transactions that succeed completely

    or fail completely Example: Booking a flight Reserve a seat and collect money XOR Do not reserve a seat, nor collect money Wednesday, August 21, 13
  21. ACID Consistency : A transaction will bring the database from

    one valid state to another - all of the “rules” of the database Example: Unique Primary Keys Wednesday, August 21, 13
  22. ACID Isolation : If two things happen at the same

    time, the system must look the same as if those two things happened sequentially Wednesday, August 21, 13
  23. ACID Isolation : If two things happen at the same

    time, the system must look the same as if those two things happened sequentially Example: Incrementing a number Wednesday, August 21, 13
  24. ACID Isolation : If two things happen at the same

    time, the system must look the same as if those two things happened sequentially Example: Incrementing a number If two operations add 1 to a number, that number should go up by two, rather than only 1. Wednesday, August 21, 13
  25. ACID Durability: Once changes are posted, they remain so, even

    in the event of power loss or other serious unpredictable but inevitable problems. Wednesday, August 21, 13
  26. ACID Durability: Example: Buying something with a debit card Once

    changes are posted, they remain so, even in the event of power loss or other serious unpredictable but inevitable problems. Wednesday, August 21, 13
  27. ACID Durability: Example: Buying something with a debit card Money

    is taken away from my account, and given to the merchant account - even if power is lost between those two events. Once changes are posted, they remain so, even in the event of power loss or other serious unpredictable but inevitable problems. Wednesday, August 21, 13
  28. Think of a partition as latency Wednesday, August 21, 13

  29. Think of a partition as latency Failing to get to

    Consistency within an arbitrary amount of time means that you’re in “partition mode” Wednesday, August 21, 13
  30. Think of a partition as latency Failing to get to

    Consistency within an arbitrary amount of time means that you’re in “partition mode” This happens often over a wide area, which is why most people opt for Eventual Consistency Wednesday, August 21, 13
  31. BASE Wednesday, August 21, 13

  32. BASE (A mnemonic more than an acronym) Wednesday, August 21,

    13
  33. BASE (A mnemonic more than an acronym) Basically Available Wednesday,

    August 21, 13
  34. BASE (A mnemonic more than an acronym) Basically Available Soft

    State Wednesday, August 21, 13
  35. BASE (A mnemonic more than an acronym) Basically Available Soft

    State Eventually Consistent Wednesday, August 21, 13
  36. Sometimes read availability of a subset of relevant data is

    the most important. (Twitter, Facebook) Wednesday, August 21, 13
  37. Sometimes read availability of a subset of relevant data is

    the most important. (Twitter, Facebook) Sometimes atomic, consistent data is the most important. (banks, plane tickets) Wednesday, August 21, 13
  38. Sometimes read availability of a subset of relevant data is

    the most important. (Twitter, Facebook) Sometimes atomic, consistent data is the most important. (banks, plane tickets) Sometimes partitions are designed into the expectations of the system. (email, texts) Wednesday, August 21, 13
  39. All of these decisions depend on the software you’re writing

    Wednesday, August 21, 13
  40. All of these decisions depend on the software you’re writing

    There is no “right” set of compromises to choose. Wednesday, August 21, 13