I created following example of actors in Scala: http://pastebin.com/pa3WVpKy Without throttling (reducing number of SendMoney messages) that occurs in lines:
val processed = iterations - counter.getCount/2
if (processed < i - banksCount * 5) Thread.sleep(1)
message processing in this test is very slow (especially when there are few bank actors).
That's because actors' mailboxes are full of SendMoney messages and receiving ReadAccountResponse messages takes a long time (they are usually almost at the end of mailbox, and whole mailbox must be scanned). How to improve mailbox scan time in such cases? Maybe there is a possibility to define some messages as high priority? It would be great to have two mailboxes - one for usual messages and one for high priority ones. The high priority mailbox could be scanned first. Also "reply" method could send messages to high priority mailbox automatically. Or maybe create two mailboxes - for usual messages and responses? What's your oppinion?
Regards Wojciech Durczyński