What, Why, and How Cloudstate?

Reading Time: 4 minutes

In this article, we would be talking about Lightbend’s Cloudstate. We have been talking about Serverless a lot lately and there are a couple of reasons for that. Serverless computing will provide greater scalability, more flexibility, and quicker time to release at reduced cost and this is the reason everybody is after it. Is serverless architecture enough to drive all this we talked about just now? The answer is no, of course. Also, State management has been absolutely challenging in serverless computing but Cloudstate will make it possible for us, wondering how? Keep reading the article until and you will learn it. The Lightbend’s Cloudstate which was released in August last year(2019) has proved to be a game-changer here as it provides stateful serverless computing, Cloudstate brings powerful new distributed and durable state management primitives based on Akka to the Serverless paradigm. Serving of stateful functions powered by Akka Cluster. That was all for the introduction, let’s talk about Cloudstate in detail below.

What is Cloudstate? 

CloudState is essentially an initiative to define what is “Serverless 2.0” which is probably more than just serverless computing where there is no state maintained or it’s a responsibility of the developer but with Lightbend’s cloudstate, managing state will never be a developer’s responsibility. Those who have worked with cloud applications, distributed systems know that state is actually the hardest thing to deal with. However, cloudstate provides distributed state management patterns for Serverless computing.

Cloudstate is a specification, protocol, and reference implementation for providing distributed state management patterns suitable for Serverless computing. The current supported and envisioned patterns include:

  1. Event Sourcing
  2. Conflict-Free Replicated Data Types (CRDTs)
  3. Key-Value storage
  4. P2P messaging
  5. CQRS read side projections

Why do we need Cloudstate?

Why do we really need Cloudstate when we have other players in the market for cloud computing? This can be answered if you could think of state management in cloud-based applications. So, the cloudstate will change the game for you as it will make services stateful.
Not only stateful, but you can also make the most of fast data/streaming along with reactive technologies.

Current challenges/limitations with Serverless computing?

  • State Management
  • Move with Fast Data/Streaming
  • Being Reactive

How cloudstate will address these challenges?
So, cloudstate is called Serverless 2.0 as it will address all the challenges we have with serverless computing which we talked about.

Let’s talk about how it will actually handle the challenges with serverless.

Provides scalable, configurable, state management strategies to relieve this responsibility from the developers.
Scale services intelligently and provide in-depth observability.
Allow developers to focus on their domain problem, rather than how the state is managed.

Cloudstate consists of two things.

  1. A standards effort—defining a specification, protocol between the user functions and the backend, and a TCK.
  2. A reference implementation—implementing the backend and a set of client API libraries in different languages.

Cloudstate’s reference implementation is leveraging Knative, gRPC, Akka Cluster, and GraalVM running on Kubernetes, allowing applications to not only scale efficiently but to manage distributed state reliably at scale while maintaining its global or local level of data consistency.

The reactive technologies to the Cloud Native ecosystem break down the final impediment standing in the way of a Serverless platform for general-purpose application development—with true elastic scalability, high resilience, and global deployment, in the Kubernetes ecosystem. This makes cloudstate perfect for the development of cloud-based applications that are fast and reactive in nature.

How can we use Cloudstate?

Cloudstate language support

Cloudstate is indeed polyglot and you can write cloud-based applications in any language that supports gRPC. Cloudstate essentially provides language-specific libraries to get started with Cloudstate. Currently, cloudstate has support for the following languages.

  • Javascript
  • Java
  • Go
  • Kotlin
  • Dart

Cloudstate with Java

You can write stateful services in Java with Cloudstate. What would be pre-requisites to get started?

A. Java version – You would need at least Java8 on your system
B. Build tool – Cloudstate does not require any specific build tool so you can choose any.
C. protoc – Since Cloudstate is based on gRPC, you need a protoc compiler to compile gRPC protobuf descriptors. While this can be done by downloading, installing, and running protoc manually, most popular build tools have a protoc plugin that will automatically compile protobuf descriptors during your build.
D. docker – Cloudstate runs in Kubernetes using Docker. So, you will need Docker to build a container that you can deploy to Kubernetes.

In addition to the above, you will need to install the Cloudstate java support library, which can be done as follows:


Maven

SBT


Gradle

That’s pretty much it from the article. In the next blog, I will be talking about writing an application in Java with Cloudstate. If you have any feedback or queries, please do let me know in the comments. Also, if you liked the article, please give me a thumbs up and I will keep writing blogs like this for you in the future as well. Keep reading and Keep coding 🙂

References – https://www.lightbend.com/cloudstate-by-lightbend


Knoldus-blog-footer-image

Written by 

Deepak is a Software Consultant having experince of more than 5 years . He is very enthusiastic towards his work and is a good team player. He has sound knowledge of different technologies which include Java, C++, C, HTML, CSS, Javascript, C# always keen to learn new technologies.