Category Archives: Akka

I use Play Framework to build web application. I also use Akka and Spark in my projects. Currently, my programming language is Scala, even though in the past, I used C/C++, Python, and etc. But I’m still not really understand what is Typesafe Reactive Platform. In this post, I want to reveal its truth.

What is the Problem?

Every solution should try to solve one problem. So what is the problem which Typesafe Reactive Platform wants to deal with?

In the past, a large application had tens or so servers, seconds of response time, hours of offline maintenance and gigabytes of data. Old solutions emphasized on managing servers and containers. Scaling was achieved through buying more larger servers and concurrent processing via multi-threading.

But today applications are deployed on cloud-based clustering running thousands of multicore processors, dealing with thousand requests and handling petabytes. So old traditional scaling method is not suitable for new updated requirements.

What is Reactive Platform?

Because old solution is not good enough, we introduce a new solution, named Reactive Platform. This platform allows developers to build systems which are responsive resilient, elastic, and message-driven in order to deliver highly responsive user experiences with a real-time feel, backed by a elastic and resilient application stack, ready to be deployed on multicore and cloud computing architectures.

So Typesafe Reactive Platform is this kind of platform, which contains Play Framework, Akka, Scala, Activator and Spark. It is powerful tool to build modern applications that react to events, react to load, react to failure, and react to users.

Before we touch Akka, we should know what is Akka. Akka uses Actor model to provide a platform to build a correct concurrent and scalable applications. Here we notice two key words, one is concurrent, the other is scalable. (Here I haven’t think out a good example to explain it, leave it here, I will add more in the future…)

Actor model? So what is actor. We can treat actor as thread entity, which has a mailbox. Actor can be created by system.actorOf, use receive to obtain mailbox’s message, and ! to send message to mailbox. Actor is lighter than thread, because actor can re-use thread. One actor can take up multiple threads, one thread can be used by multiple actor. So there is 1 to 1 relationship between actor and thread, which depends on dispatcher.

Following we just introduce very simply way to use Akka.

1. Concept

It is easy to define Actor by inheriting from akka.actor.Actor. You just need to implement receive method.