Pro Yearly is on sale from $80 to $50! »

Building Scalable Stateful Services

Building Scalable Stateful Services

The Stateless Service design principle has become ubiquitous in the tech industry for creating horizontally scalable services. However our applications do have state, we just have moved all of it to caches and databases. Today as applications are becoming more data intensive and request latencies are expected to be incredibly low, we’d like the benefits of stateful services, like data locality and sticky consistency. In this talk I will address the benefits of stateful services, how to build them so that they scale, and discuss projects from Halo and Twitter of highly distributed and scalable services that implement these techniques successfully.

9128d500301ae51524e887bb680f471d?s=128

Caitie McCaffrey

September 27, 2015
Tweet

Transcript

  1. Building Scalable Stateful Services StrangeLoop 2015

  2. Caitie McCaffrey Distributed Systems Engineer Tech Lead Observability @ Twitter

    @caitie caitiem.com
  3. Stateless Services Service

  4. Stateless Services Service

  5. Stateless Services Service Service

  6. Stateless Services Service Service

  7. Stateless Services Service Service

  8. Stateless Services Service Service Service

  9. Stateless Services Service Service Service

  10. Stateless Services Service Service Service

  11. Stateless Services Service Service Service Service

  12. Stateless Services Service Service Service Service

  13. Stateless Services Service Service Service Service

  14. Stateless Services Service Service Service Service Service

  15. Stateless Services Service Service Service Service Service

  16. Data Shipping Paradigm Service Service Service

  17. Data Shipping Paradigm Service Service Service

  18. Data Shipping Paradigm Service Service Service

  19. Data Shipping Paradigm Service Service Service

  20. Data Shipping Paradigm Service Service Service

  21. Data Shipping Paradigm Service Service Service

  22. Data Shipping Paradigm Service Service Service

  23. Data Shipping Paradigm Service Service Service

  24. Data Shipping Paradigm Service Service Service

  25. Data Shipping Paradigm Service Service Service

  26. Data Shipping Paradigm Service Service Service

  27. Data Shipping Paradigm Service Service Service

  28. Data Shipping Paradigm Service Service Service

  29. Data Shipping Paradigm Service Service Service

  30. Data Shipping Paradigm Service Service Service

  31. Overview Benefits Building Real World Caution

  32. Data Locality For Low Latency & Data Intensive Services

  33. Function Shipping Paradigm Service Service Service

  34. Function Shipping Paradigm Service Service Service

  35. Function Shipping Paradigm Service Service Service

  36. Function Shipping Paradigm Service Service Service

  37. Function Shipping Paradigm Service Service Service

  38. Function Shipping Paradigm Service Service Service

  39. Function Shipping Paradigm Service Service Service

  40. Function Shipping Paradigm Service Service Service

  41. Function Shipping Paradigm Service Service Service

  42. Function Shipping Paradigm Service Service Service

  43. Function Shipping Paradigm Service Service Service

  44. Sticky Connections & Consistency Additional Available Consistency Models

  45. Linearizable Sequential Causal Pipelined Random Access Memory Read Your Write

    Monotonic Read Monotonic Write Write From Read Consistency Models CP Consistency AP Consistency
  46. 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
  47. - 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.”
  48. Building Sticky Connections For Low Latency & Data Intensive Services

  49. Building Sticky Connections

  50. Building Sticky Connections

  51. Persistent Connections Load Balancing Problems No Stickiness Once Connection Breaks

    Problems
  52. Persistent Connections Load Balancing Problems No Stickiness Once Connection Breaks

    Problems
  53. Routing Logic • Cluster Membership • Work Distribution Problems to

    Solve
  54. Routing Logic • Cluster Membership • Work Distribution Problems to

    Solve
  55. Routing Logic • Cluster Membership • Work Distribution Problems to

    Solve
  56. Static Cluster Membership

  57. Static Cluster Membership

  58. Static Cluster Membership

  59. Dynamic Cluster Membership

  60. Dynamic Cluster Membership

  61. Dynamic Cluster Membership

  62. Dynamic Cluster Membership

  63. Dynamic Cluster Membership

  64. Dynamic Cluster Membership Gossip Protocols Consensus Systems Availability vs Consistency

  65. Work Distribution Consistent Hashing Distributed Hash Tables Random Placement

  66. Random Placement Write Anywhere Read from Everywhere

  67. Random Placement Write Anywhere Read from Everywhere

  68. Random Placement Write Anywhere Read from Everywhere

  69. Random Placement Write Anywhere Read from Everywhere

  70. Random Placement Write Anywhere Read from Everywhere

  71. Random Placement Write Anywhere Read from Everywhere

  72. Random Placement Write Anywhere Read from Everywhere

  73. 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
  74. Distributed Hash Table Non- Deterministic Placement Node B Node A

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

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

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

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

    Node C
  79. Stateful Services In the Real World

  80. 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
  81. 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
  82. 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
  83. 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 +
  84. 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 +
  85. 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 +
  86. 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
  87. 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
  88. 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
  89. Orleans Cluster Orleans Distributed Hash Table

  90. Orleans Cluster Orleans Distributed Hash Table

  91. Orleans Cluster Orleans Distributed Hash Table

  92. Orleans Cluster Orleans Distributed Hash Table

  93. Orleans Cluster Orleans Distributed Hash Table

  94. Orleans Cluster Orleans Distributed Hash Table

  95. Orleans Cluster Orleans Distributed Hash Table

  96. Orleans Cluster Orleans Distributed Hash Table

  97. Caution Stateful Services Ahead

  98. Unbounded Data Structures Implicit Assumptions are the Killer of Distributed

    Systems
  99. Memory Management Get Ready to Make Friends with the Garbage

    Collector Profiler
  100. Reloading State • First Connection • Recovering From Crashes •

    Deploying New Code
  101. 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.”
  102. Conclusion Data Locality & Available Consistency Cluster Membership & Work

    Distribution Successful Statefull Real World Systems Caution: Some New Challenges
  103. Should I Read Papers?

  104. Should I Read Papers? YES!

  105. Thank You Kyle Kingsbury Chris Meiklejohn Tom Santero Ines Sombra

    @Caitie
  106. None
  107. None