Search code examples
akkaactor

Is Akka real actor model?


When working with Scala Akka, we still think about blocking IO, and try to avoid it with patterns, I feel it makes no difference from using threads. Implicitly async IO is a huge differentiator, Erlang and Go provide it at language level, while Scala Akka does not. I feel Scala Akka is not real actor model.

There's a popular blog post Don't use Actors for concurrency, but it's not really a problem of actor model, it's purely a problem of Akka.


Solution

  • Akka implements the Actor Model as specified by Carl Hewitt et al in 1973: an actor can upon reception of a message

    • send a finite number of messages to actors it knows
    • create a finite number of actors
    • determine the behavior to be applied to the next message

    Nowhere does this say anything about how exactly I/O is supposed to be handled. Translating blocking method calls into actor-suspending method calls automatically is on the other hand a violation of the model: actors only act upon messages, nothing else, and declaring some arbitrary method calls to prevent that from happening for some (possibly unbounded) time is not part of the model.

    Akka provides IO facilities for network operations that are presented in an Actor Model fashion by exposing an ActorRef that commands can be sent to and results can be received from. Akka Streams includes asynchronous consumption and production of data from and to I/O channels.

    I hope this explains why my overall answer is that the premise of the question is flawed.