Akka actor cardinality

78 views Asked by At

After reading most of the Akka docs, I still don't understand something fairly fundamental to Akka: actor cardinality.

Meaning, if I have a particular actor, say FizzActor, does Akka ever only create 1 instance of it, or does it spawn n-instances of it as needed? If it can spawn multiple instances of an actor class, then is this configurable (if so how/where?), or does Akka alone determine how many instances to create? Does stopping/restarting/resuming this actor class perform the action on all instances of the actor or just the one child instance? Can I assume that Akka coordinates state changes across all FizzActor instances, so that each time I get an ActorRef to it, I see a consistent state?

None of these seem to be covered in the docs!

1

There are 1 answers

2
Konrad 'ktoso' Malawski On

Akka's primary philosophy is "no magic", i.e. if you create an actor that's what happens - one Actor is created. Refer to the docs on Creating Actors with Props for a deeper explanation.

The one case where Akka takes care of starting multiple Actors in your stead is Pool Routers, which as explained in the docs:

Pool - The router creates routees as child actors and removes them from the router if they terminate