Introducing Kalix - High-performance microservices and APIs with no operations required. Start for free.
akka-serverless serverless

Developing Serverless Applications - Part 3: Stateful Entities and Use Cases


Akka Serverless is now Kalix. Learn more at

Knock knock: it’s your application data

We all want the benefits of serverless: flexible scaling to meet demand being handled by a hosted platform, not planned for months ahead, and making fault tolerance and availability the platform’s responsibility–and not the developer’s or operator’s–are incredible organizational efficiencies.

This means that to make serverless applications worth it at all for complex enterprise applications, we need to continuously process data in close to real-time, mining knowledge from never-ending streams of data.

This data also often needs to be processed in a distributed way—for scalability and throughput—before it is ready to be stored by the persistence layer. Enter stateful entities: by combining domain state and logic into a single “entity”, ensuring co-location of data and processing, we get a powerful, yet simple, abstraction for designing data-centric services and systems. Stateful entities providing the following benefits to development teams:

  • Low latency services - effectively in-memory state, backed by durable storage, reduces latency for data-centric operations
  • Unlimited scale - by eliminating points of contention at the DB, stateful services can scale to millions of messages per second
  • Designed for data-centric services - multiple data models (like Event Sourcing, CQRS, Streaming and CRDTs) enable complex use cases like digital twins for IoT, real-time financial services, telemedicine, streaming media and gaming, etc

In Part 3 of our series Developing Serverless Applications, we dive into the role of stateful entities, why this matters, and serverless use cases for application developers.

Stateful serverless carries state in-memory

Working with stateful entities enables developers to look at the challenge of distributed state in a different way, with a different design. It puts data at the center, not on the sidelines, as in the image below:

Akka Serverless utilizes in-memory state while persisting data and events to data sources that you don’t need to manage or think about.

Above: Akka Serverless utilizes in-memory state while persisting data and events to data sources that you don’t need to manage or think about.

  1. Messages get sent to your service and Akka Serverless sends your service the data it needs.
  2. These messages are “commands”, what is it you want to do? It could be checking out your cart when you’re ordering items online or paying a bill.
  3. The business logic in your service takes these commands and processes them.
  4. After processing, your business logic updates and persists your state. Your business logic can also store an event in an append-only log.

Akka Serverless - stateful entities enable fully-fledged enterprise applications

IoT Platforms

  • Digital twins
  • In-line analytics
  • Lightweight processing

Real-Time Financial Services

  • Fraud detection
  • In-line machine learning
  • In-app personalization

Web-Based Gaming

  • User sessions & game state
  • In-line analytics
  • In-app personalization

Messengers & Chatbots

  • Chat sessions
  • Online/Offline presence
  • Chatbot routing

Streaming Media Platforms

  • Viewer state
  • In-line analytics
  • In-app personalization

Distributed eCommerce Systems

  • Resilient carts
  • In-app and in-store personalization
  • In-line analytics

With developers left empty-handed with stateless functions only, this is where Akka Serverless comes into play. Our vision for Akka Serverless is to have a stateful serverless Platform-as-a-Service where the data your service needs is injected as needed in real-time.

This is especially applicable to extremely-low-latency services like those for digital twins for IoT, Financial Services, Telemedicine, Streaming Media and Gaming, and other use cases.

Akka Serverless combines the scalability and cost benefits of serverless infrastructure with the data management and responsiveness of stateful services. This adds up to one managed, cloud-based environment–not multiple cloud services that need to be configured and managed separately. Here is a 90-second video to give you an idea of what Akka Serverless is all about.

Watch on YouTube

What do developers get with Akka Serverless?

Akka Serverless democratizes the ability for developers to utilize advanced data access patterns with an easy on-ramp to serverless that eliminates a lot of the distractions and manual work related to infrastructure and databases.

  • Democratizes advanced data access patterns - Until now, Event sourcing, CQRS, Streaming, CRUD and CRDTs in a serverless architecture have not been made simple for developers to access for complex low-latency use cases
  • Easy access to serverless for developers - multiple languages and no new tools with a pure focus on the code gets developers up and running in minutes
  • Less distractions and overhead - no low-level plumbing for clusters and shards, no databases, message queues, or infrastructure to configure, tune, and manage

In the next part, we look at how it all works in Akka Serverless. We’ll introduce the various data access patterns used for stateful entities and stateless functions, including the ability to mix and match between Event Sourcing, CQRS, and CRUD for key-value storage, all out of the box.

Learn more in this series




Akka Serverless is now Kalix. Learn more at


The Total Economic Impact™
Of Lightbend Akka Platform

  • 139% ROI
  • 50% to 75% faster time-to-market
  • 20x increase in developer throughput
  • <6 months Akka Platform pays for itself