Slide 1

Slide 1 text

Building Scalable Stateful Services StrangeLoop 2015

Slide 2

Slide 2 text

Caitie McCaffrey Distributed Systems Engineer Tech Lead Observability @ Twitter @caitie caitiem.com

Slide 3

Slide 3 text

Stateless Services Service

Slide 4

Slide 4 text

Stateless Services Service

Slide 5

Slide 5 text

Stateless Services Service Service

Slide 6

Slide 6 text

Stateless Services Service Service

Slide 7

Slide 7 text

Stateless Services Service Service

Slide 8

Slide 8 text

Stateless Services Service Service Service

Slide 9

Slide 9 text

Stateless Services Service Service Service

Slide 10

Slide 10 text

Stateless Services Service Service Service

Slide 11

Slide 11 text

Stateless Services Service Service Service Service

Slide 12

Slide 12 text

Stateless Services Service Service Service Service

Slide 13

Slide 13 text

Stateless Services Service Service Service Service

Slide 14

Slide 14 text

Stateless Services Service Service Service Service Service

Slide 15

Slide 15 text

Stateless Services Service Service Service Service Service

Slide 16

Slide 16 text

Data Shipping Paradigm Service Service Service

Slide 17

Slide 17 text

Data Shipping Paradigm Service Service Service

Slide 18

Slide 18 text

Data Shipping Paradigm Service Service Service

Slide 19

Slide 19 text

Data Shipping Paradigm Service Service Service

Slide 20

Slide 20 text

Data Shipping Paradigm Service Service Service

Slide 21

Slide 21 text

Data Shipping Paradigm Service Service Service

Slide 22

Slide 22 text

Data Shipping Paradigm Service Service Service

Slide 23

Slide 23 text

Data Shipping Paradigm Service Service Service

Slide 24

Slide 24 text

Data Shipping Paradigm Service Service Service

Slide 25

Slide 25 text

Data Shipping Paradigm Service Service Service

Slide 26

Slide 26 text

Data Shipping Paradigm Service Service Service

Slide 27

Slide 27 text

Data Shipping Paradigm Service Service Service

Slide 28

Slide 28 text

Data Shipping Paradigm Service Service Service

Slide 29

Slide 29 text

Data Shipping Paradigm Service Service Service

Slide 30

Slide 30 text

Data Shipping Paradigm Service Service Service

Slide 31

Slide 31 text

Overview Benefits Building Real World Caution

Slide 32

Slide 32 text

Data Locality For Low Latency & Data Intensive Services

Slide 33

Slide 33 text

Function Shipping Paradigm Service Service Service

Slide 34

Slide 34 text

Function Shipping Paradigm Service Service Service

Slide 35

Slide 35 text

Function Shipping Paradigm Service Service Service

Slide 36

Slide 36 text

Function Shipping Paradigm Service Service Service

Slide 37

Slide 37 text

Function Shipping Paradigm Service Service Service

Slide 38

Slide 38 text

Function Shipping Paradigm Service Service Service

Slide 39

Slide 39 text

Function Shipping Paradigm Service Service Service

Slide 40

Slide 40 text

Function Shipping Paradigm Service Service Service

Slide 41

Slide 41 text

Function Shipping Paradigm Service Service Service

Slide 42

Slide 42 text

Function Shipping Paradigm Service Service Service

Slide 43

Slide 43 text

Function Shipping Paradigm Service Service Service

Slide 44

Slide 44 text

Sticky Connections & Consistency Additional Available Consistency Models

Slide 45

Slide 45 text

Linearizable Sequential Causal Pipelined Random Access Memory Read Your Write Monotonic Read Monotonic Write Write From Read Consistency Models CP Consistency AP Consistency

Slide 46

Slide 46 text

Linearizable Sequential Causal Pipelined Random Access Memory Read Your Write Monotonic Read Monotonic Write Write From Read CP Consistency AP Consistency AP Consistency w/ Sticky Connections Consistency Models

Slide 47

Slide 47 text

- Werner Vogel 2007 “Whether or not read-your-write, session and monotonic consistency can be achieved depends in general on the "stickiness" of clients to the server that executes the distributed protocol for them… Using sessions, which are sticky, makes this explicit and provides an exposure level that clients can reason about.”

Slide 48

Slide 48 text

Building Sticky Connections For Low Latency & Data Intensive Services

Slide 49

Slide 49 text

Building Sticky Connections

Slide 50

Slide 50 text

Building Sticky Connections

Slide 51

Slide 51 text

Persistent Connections Load Balancing Problems No Stickiness Once Connection Breaks Problems

Slide 52

Slide 52 text

Persistent Connections Load Balancing Problems No Stickiness Once Connection Breaks Problems

Slide 53

Slide 53 text

Routing Logic • Cluster Membership • Work Distribution Problems to Solve

Slide 54

Slide 54 text

Routing Logic • Cluster Membership • Work Distribution Problems to Solve

Slide 55

Slide 55 text

Routing Logic • Cluster Membership • Work Distribution Problems to Solve

Slide 56

Slide 56 text

Static Cluster Membership

Slide 57

Slide 57 text

Static Cluster Membership

Slide 58

Slide 58 text

Static Cluster Membership

Slide 59

Slide 59 text

Dynamic Cluster Membership

Slide 60

Slide 60 text

Dynamic Cluster Membership

Slide 61

Slide 61 text

Dynamic Cluster Membership

Slide 62

Slide 62 text

Dynamic Cluster Membership

Slide 63

Slide 63 text

Dynamic Cluster Membership

Slide 64

Slide 64 text

Dynamic Cluster Membership Gossip Protocols Consensus Systems Availability vs Consistency

Slide 65

Slide 65 text

Work Distribution Consistent Hashing Distributed Hash Tables Random Placement

Slide 66

Slide 66 text

Random Placement Write Anywhere Read from Everywhere

Slide 67

Slide 67 text

Random Placement Write Anywhere Read from Everywhere

Slide 68

Slide 68 text

Random Placement Write Anywhere Read from Everywhere

Slide 69

Slide 69 text

Random Placement Write Anywhere Read from Everywhere

Slide 70

Slide 70 text

Random Placement Write Anywhere Read from Everywhere

Slide 71

Slide 71 text

Random Placement Write Anywhere Read from Everywhere

Slide 72

Slide 72 text

Random Placement Write Anywhere Read from Everywhere

Slide 73

Slide 73 text

Consistent Hashing Deterministic Placement Node A Node B Node C NodeD Consistent Hashing & Random Trees: Distributed caching protocols for relieving hot spots on the World Wide Web

Slide 74

Slide 74 text

Distributed Hash Table Non- Deterministic Placement Node B Node A Node C

Slide 75

Slide 75 text

Distributed Hash Table Non- Deterministic Placement Node B Node A Node C

Slide 76

Slide 76 text

Distributed Hash Table Non- Deterministic Placement Node B Node A Node C

Slide 77

Slide 77 text

Distributed Hash Table Non- Deterministic Placement Node B Node A Node C

Slide 78

Slide 78 text

Distributed Hash Table Non- Deterministic Placement Node B Node A Node C

Slide 79

Slide 79 text

Stateful Services In the Real World

Slide 80

Slide 80 text

Scuba is a fast, scalable, distributed, in-memory database built at Facebook. It is the workhorse behind code regression analysis & bug report, revenue, and performance debugging Fan-out request to all machines in the cluster Compose Results Return Results and Completeness

Slide 81

Slide 81 text

Scuba is a fast, scalable, distributed, in-memory database built at Facebook. It is the workhorse behind code regression analysis & bug report, revenue, and performance debugging Fan-out request to all machines in the cluster Compose Results Return Results and Completeness

Slide 82

Slide 82 text

Scuba is a fast, scalable, distributed, in-memory database built at Facebook. It is the workhorse behind code regression analysis & bug report, revenue, and performance debugging Fan-out request to all machines in the cluster Compose Results Return Results and Completeness

Slide 83

Slide 83 text

Uber Ringpop is an open- source Node.js library that brings application-layer sharding to many of their dispatching platform services. Swim Gossip Protocol Consistent Hashing +

Slide 84

Slide 84 text

Uber Ringpop is an open- source Node.js library that brings application-layer sharding to many of their dispatching platform services. Swim Gossip Protocol Consistent Hashing +

Slide 85

Slide 85 text

Uber Ringpop is an open- source Node.js library that brings application-layer sharding to many of their dispatching platform services. Swim Gossip Protocol Consistent Hashing +

Slide 86

Slide 86 text

Orleans Cluster Orleans is a runtime and Programming model for building distributed systems based on the Actor Model from the eXtreme Computing Group at MSR Gossip Protocol Consistent Hashing + + Distributed Hash Table Actor Actor Actor Actor Actor

Slide 87

Slide 87 text

Orleans Cluster Orleans is a runtime and Programming model for building distributed systems based on the Actor Model from the eXtreme Computing Group at MSR Gossip Protocol Consistent Hashing + + Distributed Hash Table Actor Actor Actor Actor Actor

Slide 88

Slide 88 text

Orleans Cluster Orleans is a runtime and Programming model for building distributed systems based on the Actor Model from the eXtreme Computing Group at MSR Gossip Protocol Consistent Hashing + + Distributed Hash Table Actor Actor Actor Actor Actor

Slide 89

Slide 89 text

Orleans Cluster Orleans Distributed Hash Table

Slide 90

Slide 90 text

Orleans Cluster Orleans Distributed Hash Table

Slide 91

Slide 91 text

Orleans Cluster Orleans Distributed Hash Table

Slide 92

Slide 92 text

Orleans Cluster Orleans Distributed Hash Table

Slide 93

Slide 93 text

Orleans Cluster Orleans Distributed Hash Table

Slide 94

Slide 94 text

Orleans Cluster Orleans Distributed Hash Table

Slide 95

Slide 95 text

Orleans Cluster Orleans Distributed Hash Table

Slide 96

Slide 96 text

Orleans Cluster Orleans Distributed Hash Table

Slide 97

Slide 97 text

Caution Stateful Services Ahead

Slide 98

Slide 98 text

Unbounded Data Structures Implicit Assumptions are the Killer of Distributed Systems

Slide 99

Slide 99 text

Memory Management Get Ready to Make Friends with the Garbage Collector Profiler

Slide 100

Slide 100 text

Reloading State • First Connection • Recovering From Crashes • Deploying New Code

Slide 101

Slide 101 text

Fast Restarts at Facebook “Our Key Observation is that we can decouple the memory lifetime from the process lifetime. When we shutdown a server for a planned upgrade.”

Slide 102

Slide 102 text

Conclusion Data Locality & Available Consistency Cluster Membership & Work Distribution Successful Statefull Real World Systems Caution: Some New Challenges

Slide 103

Slide 103 text

Should I Read Papers?

Slide 104

Slide 104 text

Should I Read Papers? YES!

Slide 105

Slide 105 text

Thank You Kyle Kingsbury Chris Meiklejohn Tom Santero Ines Sombra @Caitie

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content