0

I have the same problem as in question: Akka Actor Priorities

I have some CPU intensive tasks that should be handled as fast as possible hence use all the resources available, but I also have even more important tasks that come in every now and then and should be handled even faster.

The solution provided there is that the two different dispatchers are constructed with separated thread pools. But I guess this only solves the problem if the CPU intensive tasks are limited to say 6 of 8 cores, and the high priority tasks can use all 8, therefore 2 cores are always guaranteed to be free for the high priority tasks. But then if no high priority tasks are available the 2 cores are idle and cannot be used for the other tasks.

I think a better solution would be to have 2 dispatchers that can use all cores but one has threads with higher priority and one with lower. And if high priority tasks come in the high priority dispatcher takes over the cores with his threads.

I know that you can set the Thread priority directly in Java, I'm not sure if this is actually translating in the desired behaviour I described above. But if so, how can I configure this behaviour from scala akka dispatchers?

Community
  • 1
  • 1
samy
  • 1,058
  • 1
  • 16
  • 38
  • I don't think you need "thread priorities". What you need here is simply a priority queue (or heap). – Alex Suo Dec 02 '15 at 10:07
  • 1
    Hm ok, fair point I guess I could use a central UnboundedPriorityMailbox for all messages and actors: http://doc.akka.io/docs/akka/2.1.2/scala/dispatchers.html#Mailbox%20configuration%20examples – samy Dec 02 '15 at 10:20

0 Answers0