19

I want to know what is the use of Akka.

I read about it from the internet, and know that it is a toolkit and uses the Actor model system. After this I studied about the Actor model system in which there are different actors that can message each other and initiate action.

I also know that Akka helps provide concurrency and avoid the locking mechanism. But even after reading all this I am unable to summarize exactly what Akka is and why we use it? Also, how is it used?

Can anyone please elaborate it to me in simple words? Thanks.

4 Answers 4

17

In a nutshell, Akka is a convenient framework for doing reactive and distributed application on the JVM. It is based on the reactive manifesto and therefore it is :

Event-driven with message passing (i.e loosely coupled)

Resilient through the use of supervision strategies, death watch and hierarchies.

Scalable and responsive thanks to saving resources with your actors sharing threads in a non-blocking way. Before, when you were challenged with concurrency problems, you used to have locking mechanisms blocking the current thread and context switching.

Disregarding the performance themselves, the actor model is also much more simple to reason about. Thinking of interactions between people (i.e actors) is easier than thinking of avoiding deadlocks and starvations. So should we always use Akka ? Well if you're a real shared state concurrency guru and you want the very best performance for specific stuff, then no. If you're like most of us, then you can.

8

Simply said, Akka saves you from the trouble of dealing with low-level concurrency primitives yourself when writing multi-threaded high performance apps. Instead you can use Actors, a higher level construct, to write your concurrent code. The same model then scales transparently (and much more "feels-right") to distributed systems, as Actors always communicate via messages, regardless if an Actor is local or on a different node.

There are different modules, like HTTP, streams or persistence - aimed at different concrete problems, but Akka's Actors would be the heart of the project.

You can look at the different activator templates to see some example apps and explanations: https://typesafe.com/activator/templates#filter:akka

2
  • Does that imply that Akka can only be used for solving concurrency problems through out a single JVM? Or can it be distributed across multiple JVMs in a cluster-like manner?
    – mdzh
    Commented Jun 6, 2017 at 13:09
  • Of course it scales out to multiple nodes, that's at the core of the model and the library :-) That is enabled by akka-cluster doc.akka.io/docs/akka/current/scala/cluster-usage.html Commented Jun 8, 2017 at 7:20
2

Akka is very useful to write server side scalable application. Using Akka, it is very easy to send messages to various nodes of your application. In simple language you can run your application in several no. of machines according to load and akka will handle its traffic.

0

Many see Akka as a easy way to solve the problem of concurrency. I would add that designing systems using the Actor model (Akka) makes it easier to reason about aspects of the system especially when Ubiquitous Language is used for both Actors and messages . Every actor is its own compartment and actors talk to other actors by passing messages as opposed to direct action invocation. this control and flexibility over messages allows us to control how and where they are executed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.