问题
I'm looking over the documentation here: http://doc.akka.io/docs/akka/2.3.3/java/dispatchers.html
We're using Akka in such a way where we have two separate dispatchers (default fork-join executors) for different actors. We're now running into some performance issues and we're looking into how we can tune the dispatcher configuration parameters and see how they affect the performance of the application.
I've looked over the documentation but don't really understand the configuration parameters. For example, just for the simple default, fork-join-executor dispatcher:
What are these and how should we configure them to see how they affect application performance?
# Min number of threads to cap factor-based parallelism number to
parallelism-min = 2
# Parallelism (threads) ... ceil(available processors * factor)
parallelism-factor = 2.0
# Max number of threads to cap factor-based parallelism number to
parallelism-max = 10
Thanks!
回答1:
This configuration depends on your hardware of course.
Say you have 2 available processors on your machine, then you can configure the number of threads that a given dispatcher will have via the parallelism-factor.
current number of thread = available processor * parallelism-factor
Then you can fix boundaries to control the result of this multiplication and avoid extreme values.
parallelism-min < current number of thread < parallelism-max
Now if you want to pick the right parallelism-factor + boundaries, you have to ask yourself how many actors at a given time your dispatcher will be responsible for.
It seems logical to assume that more actors means more threads but I strongly encourage you to monitor your system to find the root cause of your performance issues and not just randomly tweaking the configuration.
As a side note you should check the "throughput" parameter of your dispatcher as it allows you to configure the fairness of the actor's thread allocation. This can really make a big difference in case of batching-like process.
# Throughput defines the maximum number of messages to be
# processed per actor before the thread jumps to the next actor.
# Set to 1 for as fair as possible.
throughput = 100
来源:https://stackoverflow.com/questions/23902764/how-to-configure-and-tune-akka-dispatchers