Actor distribution question

Hy!

If I have N node, and want to start M actor evenly distributed with the knowledge of each created actors ref, how would you do that? Its definitly not a pool, and I think its not even a group. At the point in time I want to create the exact number of actors on the currently living nodes, send them specified messages, and subscribe to the lifecycle events.

You could run a single “manager” actor on each node that is responsible for creating the M child actors. They could be looked up either via a known path of via communicating via the manager. Alternatively if the exact distribution isn’t important then you could use Cluster Sharding and communication to N*M sharded actors that will be some what evenly distributed.

Just for clarification, I don’t want N*M actor just M.

So you would do something like:

  • A actor is getting a job
  • A actor looks up the Managers on the living nodes
  • A actor calculates the number of tasks, and the “best” distribution
  • A actor requests Task actors from the Managers
  • Manager creates Task actors
  • Task actors tells A actor that they are ready to work
  • A actor subscribe to the Task actors lifecycle events
  • A actor distributes the task to the Task actors

This is what I came up on my own too, but it seems like a general pattern to me, that is the reason I asked the question. (It’s nice to recreate existing things to learn how they works, but if there an already working build-in thing for that I would use that instead :D )

You can see how Lagom implements this in ClusterDistribution: