Search code examples
akkaactor

What is the difference between System Actor and User Actor in akka?


So I can create many actors using actor system. And I can also create many actors using SpawnProtocol. What is the difference between these two types of actors. One I can think of is - we get supervision capabilities for all the user actors. But is there any other difference? Is one more expensive than other?

enter image description here


Solution

  • For normal application actors you should always prefer spawning actors on the user side. System actors are useful for the case where an extension, for example a third party library, wants to spawn actors.

    It becomes especially important in Akka Typed since the user provides the user guardian, and there is no way for an extension to ask it to create a child with an arbitrary behavior. It would be quite inconvenient if the extension would require the user to always use SpawnProtocol as the user guardian.

    Internally some of the event stream, the TCP/UDP/DNS infrastructure, the core Cluster daemons, some of the cluster utils as well as Akka Streams spawn actors in the system namespace.