Slide 1

Slide 1 text

Jonas Bonér @jboner Towards Stateful Serverless

Slide 2

Slide 2 text

“We predict that Serverless Computing will grow to dominate the future of Cloud Computing.” - Berkeley CS Department Cloud computing simplified: a Berkeley view on serverless computing

Slide 3

Slide 3 text

FaaS FaaS = Function-as-a-Service

Slide 4

Slide 4 text

Is visionary FaaS FaaS = Function-as-a-Service

Slide 5

Slide 5 text

Is visionary Paved the way FaaS FaaS = Function-as-a-Service

Slide 6

Slide 6 text

Is visionary Paved the way Just the first step FaaS FaaS = Function-as-a-Service

Slide 7

Slide 7 text

Serverless ≠Faas

Slide 8

Slide 8 text

good use-cases For FaaS?

Slide 9

Slide 9 text

good use-cases For FaaS? Use-cases where throughput is key rather than low latency and requests can be completed in a short time window

Slide 10

Slide 10 text

good use-cases For FaaS? 1. Embarrassingly parallel processing tasks—invoked on demand & intermittently, examples include: image processing, object recognition, log analysis 2. Low traffic applications—enterprise IT services, and spiky workloads 3. Stateless web applications—serving static content form S3 (or similar) 4. Orchestration functions—integration/coordination of calls to third-party services 5. Composing chains of functions—stateless workflow management, connected via data dependencies 6. Job scheduling—CRON jobs, triggers, etc. Use-cases where throughput is key rather than low latency and requests can be completed in a short time window

Slide 11

Slide 11 text

FAAS: Hard to build General-Purpose Applications

Slide 12

Slide 12 text

1. Functions are stateless, ephemeral, short-lived: expensive to lose computational context & rehydrate 2. Durable state is always “somewhere else” 3. No co-location of state and processing 4. No direct addressability—all communication over external storage 5. Limited options for managing & coordinating distributed state 6. Limited options for modelling data consistency guarantees FAAS: Hard to build General-Purpose Applications

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

State

Slide 15

Slide 15 text

We Need Serverless Support For...

Slide 16

Slide 16 text

We Need Serverless Support For...

Slide 17

Slide 17 text

• Managing in-memory durable session state across individual requests E.g. User Sessions, Shopping Carts, Caching We Need Serverless Support For...

Slide 18

Slide 18 text

• Managing in-memory durable session state across individual requests E.g. User Sessions, Shopping Carts, Caching • Low-latency serving of dynamic in-memory models E.g. Serving of Machine Learning Models We Need Serverless Support For...

Slide 19

Slide 19 text

• Managing in-memory durable session state across individual requests E.g. User Sessions, Shopping Carts, Caching • Low-latency serving of dynamic in-memory models E.g. Serving of Machine Learning Models • Real-time stream processing E.g. Recommendation, Anomaly Detection, Prediction Serving We Need Serverless Support For...

Slide 20

Slide 20 text

• Managing in-memory durable session state across individual requests E.g. User Sessions, Shopping Carts, Caching • Low-latency serving of dynamic in-memory models E.g. Serving of Machine Learning Models • Real-time stream processing E.g. Recommendation, Anomaly Detection, Prediction Serving • Distributed resilient transactional workflows E.g. Saga Pattern, Workflow Orchestration, Rollback/Compensating Actions We Need Serverless Support For...

Slide 21

Slide 21 text

• Managing in-memory durable session state across individual requests E.g. User Sessions, Shopping Carts, Caching • Low-latency serving of dynamic in-memory models E.g. Serving of Machine Learning Models • Real-time stream processing E.g. Recommendation, Anomaly Detection, Prediction Serving • Distributed resilient transactional workflows E.g. Saga Pattern, Workflow Orchestration, Rollback/Compensating Actions • Shared collaborative workspaces E.g. Collaborative Document Editing, Blackboards, Chat Rooms We Need Serverless Support For...

Slide 22

Slide 22 text

• Managing in-memory durable session state across individual requests E.g. User Sessions, Shopping Carts, Caching • Low-latency serving of dynamic in-memory models E.g. Serving of Machine Learning Models • Real-time stream processing E.g. Recommendation, Anomaly Detection, Prediction Serving • Distributed resilient transactional workflows E.g. Saga Pattern, Workflow Orchestration, Rollback/Compensating Actions • Shared collaborative workspaces E.g. Collaborative Document Editing, Blackboards, Chat Rooms • Leader election, counting, voting …and other distributed systems patterns/protocols for coordination We Need Serverless Support For...

Slide 23

Slide 23 text

Technical Requirements

Slide 24

Slide 24 text

1. Stateful long-lived addressable virtual components Actors Technical Requirements

Slide 25

Slide 25 text

1. Stateful long-lived addressable virtual components Actors 2. Options for distributed coordination and communication patterns Pub-Sub, Point-To-Point, Broadcast—CRDTs, Sagas, etc. Technical Requirements

Slide 26

Slide 26 text

1. Stateful long-lived addressable virtual components Actors 2. Options for distributed coordination and communication patterns Pub-Sub, Point-To-Point, Broadcast—CRDTs, Sagas, etc. 3. Options for managing distributed state reliably at scale Ranging from strong to eventual consistency (durable/ephemeral) Technical Requirements

Slide 27

Slide 27 text

1. Stateful long-lived addressable virtual components Actors 2. Options for distributed coordination and communication patterns Pub-Sub, Point-To-Point, Broadcast—CRDTs, Sagas, etc. 3. Options for managing distributed state reliably at scale Ranging from strong to eventual consistency (durable/ephemeral) 4. Intelligent adaptive placement of stateful functions Physical co-location of state and processing, sharding, and sticky routing Technical Requirements

Slide 28

Slide 28 text

1. Stateful long-lived addressable virtual components Actors 2. Options for distributed coordination and communication patterns Pub-Sub, Point-To-Point, Broadcast—CRDTs, Sagas, etc. 3. Options for managing distributed state reliably at scale Ranging from strong to eventual consistency (durable/ephemeral) 4. Intelligent adaptive placement of stateful functions Physical co-location of state and processing, sharding, and sticky routing 5. Predictable performance, latency, and throughput In startup time, communication/coordination, and storage of data Technical Requirements

Slide 29

Slide 29 text

1. Stateful long-lived addressable virtual components Actors 2. Options for distributed coordination and communication patterns Pub-Sub, Point-To-Point, Broadcast—CRDTs, Sagas, etc. 3. Options for managing distributed state reliably at scale Ranging from strong to eventual consistency (durable/ephemeral) 4. Intelligent adaptive placement of stateful functions Physical co-location of state and processing, sharding, and sticky routing 5. Predictable performance, latency, and throughput In startup time, communication/coordination, and storage of data 6. Ways of managing end-to-end guarantees and correctness Technical Requirements

Slide 30

Slide 30 text

User Function Deployment FaaS Is Great At Abstracting Over Communication

Slide 31

Slide 31 text

Message In User Function Deployment FaaS Is Great At Abstracting Over Communication

Slide 32

Slide 32 text

Message In User Function Deployment Message Out FaaS Is Great At Abstracting Over Communication

Slide 33

Slide 33 text

Message In User Function Deployment Message Out FaaS With CRUD

Slide 34

Slide 34 text

Message In User Function Deployment Database Message Out FaaS With CRUD

Slide 35

Slide 35 text

Message In User Function Deployment Database Message Out Not Serverless Leaky Abstraction

Slide 36

Slide 36 text

The Problem

Slide 37

Slide 37 text

The Function is a Black BoX The Problem

Slide 38

Slide 38 text

The Problem

Slide 39

Slide 39 text

Unconstrained database access Makes it hard to Automate operations The Problem

Slide 40

Slide 40 text

“Freedom is not so much the absence of restrictions as finding the right ones, the liberating restrictions.” - Timothy keller

Slide 41

Slide 41 text

User Function Deployment FaaS Abstracting Over Communication

Slide 42

Slide 42 text

Message In User Function Deployment FaaS Abstracting Over Communication

Slide 43

Slide 43 text

Message In User Function Deployment Message Out FaaS Abstracting Over Communication

Slide 44

Slide 44 text

Message In User Function Deployment Message Out Stateful Serverless Abstracting Over State

Slide 45

Slide 45 text

Message In User Function Deployment Message Out Stateful Serverless Abstracting Over State State In

Slide 46

Slide 46 text

Message In User Function Deployment Message Out Stateful Serverless Abstracting Over State State In State Out

Slide 47

Slide 47 text

Enter

Slide 48

Slide 48 text

What Is CloudState? https://cloudstate.io

Slide 49

Slide 49 text

Overview: 1. Open Source (Apache 2.0) project What Is CloudState? https://cloudstate.io

Slide 50

Slide 50 text

Overview: 1. Open Source (Apache 2.0) project 2. Makes Stateful Serverless applications easy What Is CloudState? https://cloudstate.io

Slide 51

Slide 51 text

Overview: 1. Open Source (Apache 2.0) project 2. Makes Stateful Serverless applications easy 3. Reference implementation for a standard (protocol and spec) What Is CloudState? https://cloudstate.io

Slide 52

Slide 52 text

Overview: 1. Open Source (Apache 2.0) project 2. Makes Stateful Serverless applications easy 3. Reference implementation for a standard (protocol and spec) 4. Let’s you focus on business logic, data model, and workflow What Is CloudState? https://cloudstate.io

Slide 53

Slide 53 text

What Is CloudState? https://cloudstate.io

Slide 54

Slide 54 text

What Is CloudState? https://cloudstate.io Don’t worry about: 1. Managing: Complexities of Distributed and Concurrent systems

Slide 55

Slide 55 text

What Is CloudState? https://cloudstate.io Don’t worry about: 1. Managing: Complexities of Distributed and Concurrent systems 2. Managing: Distributed State—Consistency, Replication, Persistence

Slide 56

Slide 56 text

What Is CloudState? https://cloudstate.io Don’t worry about: 1. Managing: Complexities of Distributed and Concurrent systems 2. Managing: Distributed State—Consistency, Replication, Persistence 3. Managing: Databases, Service Meshes, and other infrastructure

Slide 57

Slide 57 text

What Is CloudState? https://cloudstate.io Don’t worry about: 1. Managing: Complexities of Distributed and Concurrent systems 2. Managing: Distributed State—Consistency, Replication, Persistence 3. Managing: Databases, Service Meshes, and other infrastructure 4. Managing: Message Routing, Scalability, Fail-over & Recovery

Slide 58

Slide 58 text

What Is CloudState? https://cloudstate.io Don’t worry about: 1. Managing: Complexities of Distributed and Concurrent systems 2. Managing: Distributed State—Consistency, Replication, Persistence 3. Managing: Databases, Service Meshes, and other infrastructure 4. Managing: Message Routing, Scalability, Fail-over & Recovery 5. Running & Operating your application

Slide 59

Slide 59 text

What Is CloudState? https://cloudstate.io

Slide 60

Slide 60 text

Technical Highlights: 1. Polyglot: Client libs in JavaScript, Java, Go—with upcoming support for Python, .NET, Rust, Swift, Scala What Is CloudState? https://cloudstate.io

Slide 61

Slide 61 text

Technical Highlights: 1. Polyglot: Client libs in JavaScript, Java, Go—with upcoming support for Python, .NET, Rust, Swift, Scala 2. PolyState: Powerful state models—Event Sourcing, CRDTs, Key Value What Is CloudState? https://cloudstate.io

Slide 62

Slide 62 text

Technical Highlights: 1. Polyglot: Client libs in JavaScript, Java, Go—with upcoming support for Python, .NET, Rust, Swift, Scala 2. PolyState: Powerful state models—Event Sourcing, CRDTs, Key Value 3. PolyDB: Supporting SQL, NoSQL, NewSQL and in-memory replication What Is CloudState? https://cloudstate.io

Slide 63

Slide 63 text

Technical Highlights: 1. Polyglot: Client libs in JavaScript, Java, Go—with upcoming support for Python, .NET, Rust, Swift, Scala 2. PolyState: Powerful state models—Event Sourcing, CRDTs, Key Value 3. PolyDB: Supporting SQL, NoSQL, NewSQL and in-memory replication 4. Leveraging Akka, gRPC, Knative, GraalVM, running on Kubernetes What Is CloudState? https://cloudstate.io

Slide 64

Slide 64 text

Cloudstate Architecture

Slide 65

Slide 65 text

Kubernetes Pod Kubernetes Pod Kubernetes Pod Cloudstate Architecture

Slide 66

Slide 66 text

Kubernetes Pod Kubernetes Pod Kubernetes Pod User Function (JavaScript, Go, Java,…) Cloudstate Architecture User Function (JavaScript, Go, Java,…) User Function (JavaScript, Go, Java,…)

Slide 67

Slide 67 text

Kubernetes Pod Kubernetes Pod Kubernetes Pod Cloudstate Proxy (Akka Sidecar) User Function (JavaScript, Go, Java,…) Cloudstate Architecture User Function (JavaScript, Go, Java,…) User Function (JavaScript, Go, Java,…)

Slide 68

Slide 68 text

Kubernetes Pod Kubernetes Pod Kubernetes Pod Cloudstate Proxy (Akka Sidecar) User Function (JavaScript, Go, Java,…) Cloudstate Architecture User Function (JavaScript, Go, Java,…) User Function (JavaScript, Go, Java,…)

Slide 69

Slide 69 text

Kubernetes Pod Kubernetes Pod Kubernetes Pod Cloudstate Proxy (Akka Sidecar) User Function (JavaScript, Go, Java,…) Cloudstate Architecture User Function (JavaScript, Go, Java,…) User Function (JavaScript, Go, Java,…) gRPC

Slide 70

Slide 70 text

Kubernetes Pod Kubernetes Pod Kubernetes Pod Cloudstate Proxy (Akka Sidecar) User Function (JavaScript, Go, Java,…) Cloudstate Architecture User Function (JavaScript, Go, Java,…) User Function (JavaScript, Go, Java,…) Datastore (Cassandra, Postgres, Spanner,…) gRPC

Slide 71

Slide 71 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Kubernetes Pod User Function (JavaScript, Go, Java,…) Kubernetes Pod User Function (JavaScript, Go, Java,…)

Slide 72

Slide 72 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar

Slide 73

Slide 73 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar

Slide 74

Slide 74 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar HTTP

Slide 75

Slide 75 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar HTTP

Slide 76

Slide 76 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar HTTP

Slide 77

Slide 77 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar HTTP Gossip, State replication, Routing Gossip, State replication, Routing

Slide 78

Slide 78 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster Datastore (Cassandra, Postgres, Spanner,…) gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar HTTP Gossip, State replication, Routing Gossip, State replication, Routing

Slide 79

Slide 79 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster Datastore (Cassandra, Postgres, Spanner,…) gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar HTTP gRPC Gossip, State replication, Routing Gossip, State replication, Routing

Slide 80

Slide 80 text

Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar Akka Cluster Datastore (Cassandra, Postgres, Spanner,…) gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar gRPC Kubernetes Pod User Function (JavaScript, Go, Java,…) Akka Sidecar gRPC HTTP gRPC Events Gossip, State replication, Routing Gossip, State replication, Routing

Slide 81

Slide 81 text

CloudState helps you with (when being a managed service)

Slide 82

Slide 82 text

• Pay-as-you-go: • On-demand Instance Creation, Passivation, and Failover • Autoscaling—up and down CloudState helps you with (when being a managed service)

Slide 83

Slide 83 text

• Pay-as-you-go: • On-demand Instance Creation, Passivation, and Failover • Autoscaling—up and down • ZeroOps: • Automation of Message Routing and Delivery • Automation of State Management • Service of Record—In-Memory Cluster Sharding, Co-location of Data & Processing • Coordination State—Replication, Consistency • Automation of Deployment, Provisioning, Upgrades CloudState helps you with (when being a managed service)

Slide 84

Slide 84 text

Akka Cluster state management

Slide 85

Slide 85 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar

Slide 86

Slide 86 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar

Slide 87

Slide 87 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing https://akka.io

Slide 88

Slide 88 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 89

Slide 89 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 90

Slide 90 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 91

Slide 91 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 92

Slide 92 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 93

Slide 93 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 94

Slide 94 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 95

Slide 95 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Event Log Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 96

Slide 96 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Event Log Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log •Automatic Failover, Rehydration, and Rebalancing (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 97

Slide 97 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Event Log Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log •Automatic Failover, Rehydration, and Rebalancing https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 98

Slide 98 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Event Log Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log •Automatic Failover, Rehydration, and Rebalancing https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 99

Slide 99 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Event Log Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log •Automatic Failover, Rehydration, and Rebalancing (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 100

Slide 100 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Event Log Akka Sidecar Akka Sidecar Akka Sidecar •Actor-based Distributed Runtime •Decentralized Masterless P2P •Epidemic Gossiping, Self-healing •State Sharding & Routing on Entity Key •Forwarding of Requests (if needed) •Co-Location of State & Processing •Backed by Event Log •Automatic Failover, Rehydration, and Rebalancing (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 101

Slide 101 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •In-memory Replication of State •Gossiping State Changes •Using CRDTs •State Merged on Local Node •Highly Available (N Replicas) •Very Scalable https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 102

Slide 102 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •In-memory Replication of State •Gossiping State Changes •Using CRDTs •State Merged on Local Node •Highly Available (N Replicas) •Very Scalable (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 103

Slide 103 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •In-memory Replication of State •Gossiping State Changes •Using CRDTs •State Merged on Local Node •Highly Available (N Replicas) •Very Scalable (Key, State) (Key, State) (Key, State) https://akka.io User Function User Function User Function User Function User Function User Function User Function (Key, State) (Key, State)

Slide 104

Slide 104 text

Akka Cluster state management Akka Sidecar Akka Sidecar Akka Sidecar Akka Cluster Akka Sidecar Akka Sidecar Akka Sidecar Akka Sidecar •In-memory Replication of State •Gossiping State Changes •Using CRDTs •State Merged on Local Node •Highly Available (N Replicas) •Very Scalable https://akka.io User Function User Function User Function User Function User Function User Function User Function

Slide 105

Slide 105 text

Cloudstate Uses Better Models For Distributed State

Slide 106

Slide 106 text

battle-tested, Yet Constrained, models like: Cloudstate Uses Better Models For Distributed State

Slide 107

Slide 107 text

battle-tested, Yet Constrained, models like: Cloudstate Uses Better Models For Distributed State Event Sourcing

Slide 108

Slide 108 text

battle-tested, Yet Constrained, models like: Cloudstate Uses Better Models For Distributed State Event Sourcing CRDTs

Slide 109

Slide 109 text

battle-tested, Yet Constrained, models like: Cloudstate Uses Better Models For Distributed State Event Sourcing CRDTs Key Value

Slide 110

Slide 110 text

Event Sourced Entities Happy Path

Slide 111

Slide 111 text

Event Sourced Entities Happy Path

Slide 112

Slide 112 text

Command Event Sourced Entities Happy Path

Slide 113

Slide 113 text

Command Event Sourced Entities Happy Path

Slide 114

Slide 114 text

Command Event Sourced Entities Happy Path Command

Slide 115

Slide 115 text

Command Event Log Event Event Sourced Entities Happy Path Command

Slide 116

Slide 116 text

Command Event Event Log Event Event Sourced Entities Happy Path Command

Slide 117

Slide 117 text

Command Event Event Log Event Event Sourced Entities Happy Path Command Memory Image

Slide 118

Slide 118 text

Event Sourced Entities Happy Path

Slide 119

Slide 119 text

SAD Path, RECOVER FROM FAILURE Event Sourced Entities

Slide 120

Slide 120 text

Event Log SAD Path, RECOVER FROM FAILURE Event Sourced Entities

Slide 121

Slide 121 text

Event Log REPLAY EventS SAD Path, RECOVER FROM FAILURE Event Sourced Entities

Slide 122

Slide 122 text

Event Log REPLAY EventS SAD Path, RECOVER FROM FAILURE Command Event Sourced Entities

Slide 123

Slide 123 text

Benefits of Event Sourcing

Slide 124

Slide 124 text

Benefits of Event Sourcing ✴ One single Source of Truth with All history

Slide 125

Slide 125 text

Benefits of Event Sourcing ✴ One single Source of Truth with All history ✴ Allows for Memory Image (Durable In-Memory State)

Slide 126

Slide 126 text

Benefits of Event Sourcing ✴ One single Source of Truth with All history ✴ Allows for Memory Image (Durable In-Memory State) ✴ Avoids the Object-relational mismatch

Slide 127

Slide 127 text

Benefits of Event Sourcing ✴ One single Source of Truth with All history ✴ Allows for Memory Image (Durable In-Memory State) ✴ Avoids the Object-relational mismatch ✴ Allows others to Subscribe to state changes

Slide 128

Slide 128 text

Benefits of Event Sourcing ✴ One single Source of Truth with All history ✴ Allows for Memory Image (Durable In-Memory State) ✴ Avoids the Object-relational mismatch ✴ Allows others to Subscribe to state changes ✴ Has good Mechanical sympathy (Single Writer Principle)

Slide 129

Slide 129 text

Deployment Serverless Event Sourcing

Slide 130

Slide 130 text

User Function/entity Deployment Serverless Event Sourcing

Slide 131

Slide 131 text

User Function/entity Deployment Event Log In Serverless Event Sourcing

Slide 132

Slide 132 text

Command In User Function/entity Deployment Event Log In Serverless Event Sourcing

Slide 133

Slide 133 text

Command In User Function/entity Deployment Reply Out Event Log In Serverless Event Sourcing

Slide 134

Slide 134 text

Command In User Function/entity Deployment Reply Out Event Log In Events OUt Serverless Event Sourcing

Slide 135

Slide 135 text

Command In User Function/entity Deployment Reply Out Event Log In Events OUt Serverless Event Sourcing

Slide 136

Slide 136 text

Convergent & Commutative Replicated Data Types - Shapiro et. al. 2011 Conflict-Free Replicated Data Types

Slide 137

Slide 137 text

CRDT Convergent & Commutative Replicated Data Types - Shapiro et. al. 2011 Conflict-Free Replicated Data Types

Slide 138

Slide 138 text

CRDT Strong Eventual Consistency Replicated & Decentralized Highly Available & Very Scalable Data Types Contain Resolution Logic Always Converge Correctly Convergent & Commutative Replicated Data Types - Shapiro et. al. 2011 Conflict-Free Replicated Data Types

Slide 139

Slide 139 text

Data types Counters Registers Sets Maps Graphs (that all compose) CRDT Strong Eventual Consistency Replicated & Decentralized Highly Available & Very Scalable Data Types Contain Resolution Logic Always Converge Correctly Convergent & Commutative Replicated Data Types - Shapiro et. al. 2011 Conflict-Free Replicated Data Types

Slide 140

Slide 140 text

CRDTs are…

Slide 141

Slide 141 text

CRDTs are… Associative Batch-insensitive (grouping doesn't matter) a+(b+c)=(a+b)+c

Slide 142

Slide 142 text

CRDTs are… Associative Batch-insensitive (grouping doesn't matter) a+(b+c)=(a+b)+c Commutative Order-insensitive (order doesn't matter) a+b=b+a

Slide 143

Slide 143 text

CRDTs are… Associative Batch-insensitive (grouping doesn't matter) a+(b+c)=(a+b)+c Commutative Order-insensitive (order doesn't matter) a+b=b+a Idempotent Retransmission-insensitive (duplication does not matter) a+a=a

Slide 144

Slide 144 text

Deployment Serverless CRDTs

Slide 145

Slide 145 text

User Function/entity Deployment Serverless CRDTs

Slide 146

Slide 146 text

User Function/entity Deployment States/Deltas IN Serverless CRDTs

Slide 147

Slide 147 text

Message In User Function/entity Deployment States/Deltas IN Serverless CRDTs

Slide 148

Slide 148 text

Message In User Function/entity Deployment Message Out States/Deltas IN Serverless CRDTs

Slide 149

Slide 149 text

Message In User Function/entity Deployment Message Out States/Deltas IN States/deltas OUT Serverless CRDTs

Slide 150

Slide 150 text

Message In User Function/entity Deployment Message Out States/Deltas IN States/deltas OUT Serverless CRDTs

Slide 151

Slide 151 text

Deployment Serverless CRUD Using KeyValue

Slide 152

Slide 152 text

User Function/entity Deployment Serverless CRUD Using KeyValue

Slide 153

Slide 153 text

User Function/entity Deployment Snapshot In (By Entity KEy) Serverless CRUD Using KeyValue

Slide 154

Slide 154 text

Message In User Function/entity Deployment Snapshot In (By Entity KEy) Serverless CRUD Using KeyValue

Slide 155

Slide 155 text

Message In User Function/entity Deployment Message Out Snapshot In (By Entity KEy) Serverless CRUD Using KeyValue

Slide 156

Slide 156 text

Message In User Function/entity Deployment Message Out Snapshot In (By Entity KEy) Snapshot out (By Entity Key) Serverless CRUD Using KeyValue

Slide 157

Slide 157 text

Example CRDT Entity Presence function in a chat app github.com/cloudstateio/samples-java-chat

Slide 158

Slide 158 text

Protobuf Descriptor defining service API and messages

Slide 159

Slide 159 text

syntax = "proto3"; import "cloudstate/entity_key.proto"; package cloudstate.samples.presence; option java_package = "io.cloudstate.samples.presence"; option java_outer_classname = "PresenceProtos"; Protobuf Descriptor defining service API and messages

Slide 160

Slide 160 text

syntax = "proto3"; import "cloudstate/entity_key.proto"; package cloudstate.samples.presence; option java_package = "io.cloudstate.samples.presence"; option java_outer_classname = "PresenceProtos"; "// Messages message User { "// Entity key is the unique entity/function identifier string name = 1 [(.cloudstate.entity_key) = true]; } message OnlineStatus { bool online = 1; } message Empty { } Protobuf Descriptor defining service API and messages

Slide 161

Slide 161 text

syntax = "proto3"; import "cloudstate/entity_key.proto"; package cloudstate.samples.presence; option java_package = "io.cloudstate.samples.presence"; option java_outer_classname = "PresenceProtos"; "// Messages message User { "// Entity key is the unique entity/function identifier string name = 1 [(.cloudstate.entity_key) = true]; } message OnlineStatus { bool online = 1; } message Empty { } "// Service API service Presence { "// Connect the given user rpc Connect(User) returns (stream Empty); "// Monitor the online status of the given user rpc Monitor(User) returns (stream OnlineStatus); } Protobuf Descriptor defining service API and messages

Slide 162

Slide 162 text

CRDT Entity for online presence

Slide 163

Slide 163 text

@CrdtEntity public class PresenceEntity { private final Vote vote; "// Vote CRDT for this user. It’s auto replicated "// and keeps track how each node has voted private final String username; "// Entity Key (for sharding and routing) public PresenceEntity( Optional vote, CrdtCreationContext ctx, @EntityId String username) { … } } CRDT Entity for online presence

Slide 164

Slide 164 text

@CrdtEntity public class PresenceEntity { private final Vote vote; "// Vote CRDT for this user. It’s auto replicated "// and keeps track how each node has voted private final String username; "// Entity Key (for sharding and routing) public PresenceEntity( Optional vote, CrdtCreationContext ctx, @EntityId String username) { … } } public static void main(String""... args) { new CloudState() .registerCrdtEntity(…) .start(); } CRDT Entity for online presence

Slide 165

Slide 165 text

@CrdtEntity public class PresenceEntity { private final Vote vote; "// Vote CRDT for this user. It’s auto replicated "// and keeps track how each node has voted private final String username; "// Entity Key (for sharding and routing) public PresenceEntity( Optional vote, CrdtCreationContext ctx, @EntityId String username) { … } } "// Here we implement the Protobuf Service API, our business logic @CommandHandler public void connect(StreamedCommandContext ctx) { vote.vote(true); "// Set the user to online ctx.onCancel(cancelled "-> { "// Register cancel callback for user disconnect vote.vote(false); }); … } public static void main(String""... args) { new CloudState() .registerCrdtEntity(…) .start(); } CRDT Entity for online presence

Slide 166

Slide 166 text

@CrdtEntity public class PresenceEntity { private final Vote vote; "// Vote CRDT for this user. It’s auto replicated "// and keeps track how each node has voted private final String username; "// Entity Key (for sharding and routing) public PresenceEntity( Optional vote, CrdtCreationContext ctx, @EntityId String username) { … } } "// Here we implement the Protobuf Service API, our business logic @CommandHandler public void connect(StreamedCommandContext ctx) { vote.vote(true); "// Set the user to online ctx.onCancel(cancelled "-> { "// Register cancel callback for user disconnect vote.vote(false); }); … } public static void main(String""... args) { new CloudState() .registerCrdtEntity(…) .start(); } CRDT Entity for online presence @CommandHandler public OnlineStatus monitor(StreamedCommandContext ctx) { ctx.onChange(change "-> { "// Subscribe to Vote CRDT changes … }); … }

Slide 167

Slide 167 text

Run in Kubernetes This step is not needed when user Cloudstate as a Service (as intended)

Slide 168

Slide 168 text

# Install Cloudstate kubectl create namespace cloudstate Run in Kubernetes This step is not needed when user Cloudstate as a Service (as intended)

Slide 169

Slide 169 text

# Install Cloudstate kubectl create namespace cloudstate kubectl apply -n cloudstate -f https:"//github.com/ cloudstateio/cloudstate/releases/download/v0.4/ cloudstate-0.4.yaml Run in Kubernetes This step is not needed when user Cloudstate as a Service (as intended)

Slide 170

Slide 170 text

# Install Cloudstate kubectl create namespace cloudstate kubectl apply -n cloudstate -f https:"//github.com/ cloudstateio/cloudstate/releases/download/v0.4/ cloudstate-0.4.yaml Run in Kubernetes # Install our Presence app and Gateway kubectl apply -f https:"//raw.githubusercontent.com/ cloudstateio/samples-java-chat/master/deploy/ presence.yaml This step is not needed when user Cloudstate as a Service (as intended)

Slide 171

Slide 171 text

# Install Cloudstate kubectl create namespace cloudstate kubectl apply -n cloudstate -f https:"//github.com/ cloudstateio/cloudstate/releases/download/v0.4/ cloudstate-0.4.yaml Run in Kubernetes # Install our Presence app and Gateway kubectl apply -f https:"//raw.githubusercontent.com/ cloudstateio/samples-java-chat/master/deploy/ presence.yaml kubectl apply -f https:"//raw.githubusercontent.com/ cloudstateio/samples-java-chat/master/deploy/ gateway.yaml This step is not needed when user Cloudstate as a Service (as intended)

Slide 172

Slide 172 text

# Install Cloudstate kubectl create namespace cloudstate kubectl apply -n cloudstate -f https:"//github.com/ cloudstateio/cloudstate/releases/download/v0.4/ cloudstate-0.4.yaml Run in Kubernetes # Install our Presence app and Gateway kubectl apply -f https:"//raw.githubusercontent.com/ cloudstateio/samples-java-chat/master/deploy/ presence.yaml kubectl apply -f https:"//raw.githubusercontent.com/ cloudstateio/samples-java-chat/master/deploy/ gateway.yaml # Scale up the app to 3 nodes kubectl scale deploy/presence-deployment "--replicas 3 This step is not needed when user Cloudstate as a Service (as intended)

Slide 173

Slide 173 text

Join Us Try Out The Next Generation Stateful Serverless cloudstate.io