Balancing Workload Across Nodes with Akka 2
In Akka 2, there is a nifty little thing called the BalancingDispatcher, which will magically distribute work to a collection of Actors in the most efficient way possible (i.e. it’s a work stealing dispatcher). The SmallestMailboxRouter has this kind of feel as well. However, the BalancingDispatcher and the SmallestMailboxRouter differ in how the choice is made about who, and when to deliver the incoming message. The BalancingDispatcher dispatches a message to an Actor only when that Actor would otherwise be idle. The SmallestMailboxRouter dispatches the message to the Actor with the least number of messages in its Mailbox even while the Actor is currently working on other things.
Often times, people want the functionality of the BalancingDispatcher with the stipulation that the Actors doing the work have distinct Mailboxes on remote nodes. In this post we’ll explore the implementation of such a concept.