Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CAP Theorem

CAP Theorem

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

Liz Howard

August 21, 2013
Tweet

More Decks by Liz Howard

Other Decks in Programming

Transcript

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

    to want to replicate databases Wednesday, August 21, 13
  2. 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
  3. What is CAP Theorem? Availability We can always read and

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

    when part of the database isn’t accessible? Wednesday, August 21, 13
  5. 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
  6. Why is CAP Theorem important? Understanding how distributed systems work

    How to make things work at scale Wednesday, August 21, 13
  7. 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
  8. ACID Atomicity : A group of transactions that succeed completely

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

    or fail completely Example: Booking a flight Wednesday, August 21, 13
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. BASE (A mnemonic more than an acronym) Basically Available Soft

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

    the most important. (Twitter, Facebook) Wednesday, August 21, 13
  23. 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
  24. 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
  25. All of these decisions depend on the software you’re writing

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