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

Cloudstate—Towards Stateful Serverless

Jonas Bonér
February 05, 2020

Cloudstate—Towards Stateful Serverless

The Serverless experience is revolutionary and will grow to dominate the future of Cloud. Function-as-a-Service (FaaS) however—with its ephemeral, stateless, and short-lived functions—is only the first step. FaaS is great for processing-intensive, parallelizable workloads, moving data from A to B providing enrichment and transformation along the way. But it is quite limited and constrained in what use-cases it addresses well, which makes it very hard/inefficient to implement general-purpose application development and distributed systems protocols.

What’s needed is a next-generation Serverless platform and programming model for general-purpose application development in the new world of real-time data and event-driven systems. What is missing is ways to manage distributed state in a scalable and available fashion, support for long-lived virtual stateful services, ways to physically co-locate data and processing, and options for choosing the right data consistency model for the job.

This talk will discuss the challenges, requirements, and introduce you to our proposed solution: Cloudstate—an Open Source project building the next generation Stateful Serverless and leveraging state models such as Event Sourcing, CQRS, and CRDTs, running on Akka, gRPC, Knative, Kubernetes, and GraalVM, in a polyglot fashion with support for Go, JavaScript, Java, Swift, Scala, Python, Kotlin, and more.

Jonas Bonér

February 05, 2020
Tweet

More Decks by Jonas Bonér

Other Decks in Technology

Transcript

  1. Jonas Bonér
    @jboner
    Towards
    Stateful
    Serverless

    View Slide

  2. “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

    View Slide

  3. FaaS
    FaaS = Function-as-a-Service

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  7. Serverless ≠Faas

    View Slide

  8. good use-cases
    For FaaS?

    View Slide

  9. 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

    View Slide

  10. 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

    View Slide

  11. FAAS: Hard to build
    General-Purpose Applications

    View Slide

  12. 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

    View Slide

  13. View Slide

  14. State

    View Slide

  15. We Need Serverless Support For...

    View Slide

  16. We Need Serverless Support For...

    View Slide

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

    View Slide

  18. • 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...

    View Slide

  19. • 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...

    View Slide

  20. • 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...

    View Slide

  21. • 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...

    View Slide

  22. • 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...

    View Slide

  23. Technical Requirements

    View Slide

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

    View Slide

  25. 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

    View Slide

  26. 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

    View Slide

  27. 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

    View Slide

  28. 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

    View Slide

  29. 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

    View Slide

  30. User Function
    Deployment
    FaaS Is Great At
    Abstracting Over
    Communication

    View Slide

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

    View Slide

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

    View Slide

  33. Message In User Function
    Deployment
    Message Out
    FaaS With CRUD

    View Slide

  34. Message In User Function
    Deployment
    Database
    Message Out
    FaaS With CRUD

    View Slide

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

    View Slide

  36. The Problem

    View Slide

  37. The Function is a
    Black BoX
    The Problem

    View Slide

  38. The Problem

    View Slide

  39. Unconstrained
    database access
    Makes it hard to
    Automate
    operations
    The Problem

    View Slide

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

    View Slide

  41. User Function
    Deployment
    FaaS
    Abstracting Over
    Communication

    View Slide

  42. Message In
    User Function
    Deployment
    FaaS
    Abstracting Over
    Communication

    View Slide

  43. Message In
    User Function
    Deployment
    Message Out
    FaaS
    Abstracting Over
    Communication

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  47. Enter

    View Slide

  48. What Is CloudState?
    https://cloudstate.io

    View Slide

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

    View Slide

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

    View Slide

  51. 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

    View Slide

  52. 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

    View Slide

  53. What Is CloudState?
    https://cloudstate.io

    View Slide

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

    View Slide

  55. 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

    View Slide

  56. 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

    View Slide

  57. 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

    View Slide

  58. 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

    View Slide

  59. What Is CloudState?
    https://cloudstate.io

    View Slide

  60. 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

    View Slide

  61. 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

    View Slide

  62. 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

    View Slide

  63. 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

    View Slide

  64. Cloudstate Architecture

    View Slide

  65. Kubernetes Pod
    Kubernetes Pod
    Kubernetes Pod
    Cloudstate Architecture

    View Slide

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

    View Slide

  67. 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,…)

    View Slide

  68. 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,…)

    View Slide

  69. 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

    View Slide

  70. 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

    View Slide

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

    View Slide

  72. 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

    View Slide

  73. 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

    View Slide

  74. 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

    View Slide

  75. 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

    View Slide

  76. 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

    View Slide

  77. 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

    View Slide

  78. 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

    View Slide

  79. 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

    View Slide

  80. 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

    View Slide

  81. CloudState helps you with
    (when being a managed service)

    View Slide

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

    View Slide

  83. • 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)

    View Slide

  84. Akka Cluster state management

    View Slide

  85. Akka Cluster state management
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar

    View Slide

  86. Akka Cluster state management
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar
    Akka Cluster
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar
    Akka Sidecar

    View Slide

  87. 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

    View Slide

  88. 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

    View Slide

  89. 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

    View Slide

  90. 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

    View Slide

  91. 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

    View Slide

  92. 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

    View Slide

  93. 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

    View Slide

  94. 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

    View Slide

  95. 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

    View Slide

  96. 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

    View Slide

  97. 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

    View Slide

  98. 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

    View Slide

  99. 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

    View Slide

  100. 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

    View Slide

  101. 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

    View Slide

  102. 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

    View Slide

  103. 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)

    View Slide

  104. 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

    View Slide

  105. Cloudstate Uses Better Models
    For Distributed State

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  110. Event
    Sourced
    Entities
    Happy Path

    View Slide

  111. Event
    Sourced
    Entities
    Happy Path

    View Slide

  112. Command
    Event
    Sourced
    Entities
    Happy Path

    View Slide

  113. Command
    Event
    Sourced
    Entities
    Happy Path

    View Slide

  114. Command
    Event
    Sourced
    Entities
    Happy Path
    Command

    View Slide

  115. Command
    Event
    Log
    Event
    Event
    Sourced
    Entities
    Happy Path
    Command

    View Slide

  116. Command
    Event
    Event
    Log
    Event
    Event
    Sourced
    Entities
    Happy Path
    Command

    View Slide

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

    View Slide

  118. Event
    Sourced
    Entities
    Happy Path

    View Slide

  119. SAD Path, RECOVER FROM FAILURE
    Event
    Sourced
    Entities

    View Slide

  120. Event
    Log
    SAD Path, RECOVER FROM FAILURE
    Event
    Sourced
    Entities

    View Slide

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

    View Slide

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

    View Slide

  123. Benefits of
    Event Sourcing

    View Slide

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

    View Slide

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

    View Slide

  126. 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

    View Slide

  127. 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

    View Slide

  128. 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)

    View Slide

  129. Deployment
    Serverless
    Event Sourcing

    View Slide

  130. User Function/entity
    Deployment
    Serverless
    Event Sourcing

    View Slide

  131. User Function/entity
    Deployment
    Event Log In
    Serverless
    Event Sourcing

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  138. 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

    View Slide

  139. 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

    View Slide

  140. CRDTs are…

    View Slide

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

    View Slide

  142. 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

    View Slide

  143. 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

    View Slide

  144. Deployment
    Serverless
    CRDTs

    View Slide

  145. User Function/entity
    Deployment
    Serverless
    CRDTs

    View Slide

  146. User Function/entity
    Deployment
    States/Deltas IN
    Serverless
    CRDTs

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  151. Deployment
    Serverless
    CRUD
    Using KeyValue

    View Slide

  152. User Function/entity
    Deployment
    Serverless
    CRUD
    Using KeyValue

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  158. Protobuf Descriptor
    defining service API and messages

    View Slide

  159. 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

    View Slide

  160. 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

    View Slide

  161. 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

    View Slide

  162. CRDT Entity for online presence

    View Slide

  163. @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

    View Slide

  164. @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

    View Slide

  165. @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

    View Slide

  166. @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



    });



    }

    View Slide

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

    View Slide

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

    View Slide

  169. # 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)

    View Slide

  170. # 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)

    View Slide

  171. # 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)

    View Slide

  172. # 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)

    View Slide

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

    View Slide