Slide 1

Slide 1 text

I’m @lizTheDeveloper Director of Operations Instructor / Developer @Hackbright Academy Wednesday, August 21, 13

Slide 2

Slide 2 text

CAP Theorem Wednesday, August 21, 13

Slide 3

Slide 3 text

What is CAP Theorem? Wednesday, August 21, 13

Slide 4

Slide 4 text

What is CAP Theorem? Comes into play when we start to want to replicate databases Wednesday, August 21, 13

Slide 5

Slide 5 text

What is CAP Theorem? Consistency Wednesday, August 21, 13

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

What is CAP Theorem? Availability Wednesday, August 21, 13

Slide 8

Slide 8 text

What is CAP Theorem? Availability We can always read and write that data Wednesday, August 21, 13

Slide 9

Slide 9 text

What is CAP Theorem? Tolerance to Network Partitions Wednesday, August 21, 13

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Why is CAP Theorem important? Wednesday, August 21, 13

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

ACID Compliance Wednesday, August 21, 13

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

Think of a partition as latency Wednesday, August 21, 13

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

BASE Wednesday, August 21, 13

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

All of these decisions depend on the software you’re writing There is no “right” set of compromises to choose. Wednesday, August 21, 13