Skip to main content

The Actor Model - The Foundation of Akka and Akka Actors

Alexander Hauenstein 2 min read
The Actor Model - The Foundation of Akka and Akka Actors

The actor model was originally introduced in 1973 as an architectural concept in the paper A Universal Modular ACTOR Formalism for Artificial Intelligence to generalize various behavioral patterns such as semaphores, functions, or processes. The basis of the model are the so-called actors, which receive and send messages. These messages define the interface to the environment. In addition, the messages describe what purpose an actor serves.

Actors

An actor is thus to be viewed as a unit that serves exactly one purpose. Whereby the interface definition based on messages does not define how this purpose is fulfilled. As an advantage of interface definition through messages, the authors cite a decoupling of the interface definition from the actual logic that the actor implements to fulfill its purpose. Since it’s open how an actor fulfills its purpose, an actor can address other actors, which may only be created by the actor itself. As further advantages of the actor model, the authors cite, among other things, easy distribution across systems, easy parallelization, and easy synchronization. Distribution across multiple systems plays a decisive role particularly for horizontal scalability. The authors justify the easy synchronization by the fact that an actor processes messages in the order in which it receives them.

Akka Actors

Various frameworks have integrated and implemented the actor model to this day. innFactory uses the product Akka Actors from the Akka framework by Lightbend for using actors, which can be used in the programming languages Java and Scala. Akka Actors is Akka’s actor model implementation, which was partly inspired by the programming language Erlang. According to the architectural concept of actors, as shown in the diagram, Akka’s actors communicate only via messages. From the outside, it’s not visible with which behavior an actor processes the messages. In addition, each actor can have a mailbox in which messages can be stored until the actor has capacity to process the message. The processing of an actor is called behavior in Akka Actors. Whereby, in addition to the behavior, the state of an actor also determines how a message is processed. Thus, an actor can assume different states in which messages can be processed with different behaviors. Akka Actors abstracts the actor model to the extent that only the behavior of the actors and the messages need to be programmed. Everything else can be controlled via the configuration of the actors. This includes in particular how to deal with actors in the event of an unexpected error.

Written by Alexander Hauenstein Software Developer

Software Developer bei innFactory mit Leidenschaft für skalierbare Softwarelösungen.