klappvisor
klappvisor

Reputation: 1099

Using custom dispatcher for all user actors in Akka to avoid thread starvation for system actors

Question is about dispatcher configuration in Akka 2.5.x.

I would like to avoid thread starvation issue that may cause nodes to be quarantines because system messages are not delivered. In order to achieve that I would like to create separate dispatcher which is exactly the same as default dispatcher configuration.

I have defined custom dispatcher configuration with the name my-dispatcher {...}. Can I use the following to make Akka use this dispatcher for all user's actors?

akka.actor.deployment {
    "/**" { # <- should this work?
        dispatcher = my-dispatcher
...
}

Idea came from the following example in documentation:

# all direct children of '/user/actorC' have a dedicated dispatcher 
"/actorC/*" {
    dispatcher = my-dispatcher
}

So if I replace actorC with ** it will target all actors under /user, I would expect it to work. Does anyone do it this way? Or I need to find another solution?

Upvotes: 1

Views: 391

Answers (1)

Krzysztof Atłasik
Krzysztof Atłasik

Reputation: 22595

As far as I checked your approach is working and it overrides dispatcher in all actors under user path.

Although more conventional approach to configure the default dispatcher would by just overriding entries in config under akka.actor.default-dispatcher (you can override only some of them), for example:

akka {
  actor {
    default-dispatcher {
      fork-join-executor {
        parallelism-min = 2
      }
      throughput = 100
  }
}

If you insinst to use your dispatcher defined with different path in config as default, you could just override default-dispatcher section with my-dispatcher:

akka.actor.default-dispatcher = ${path.to.my-dispatcher}

Upvotes: 2

Related Questions