7

According to "Effective Akka" balancing dispatcher is being deprecated soon. I'm gonna start working on some (single machine) producer/consumer code that deals with processing workload of drastically different shapes. What should I use ?

I'd like the producer to block (akka block or thread block, I care not) (similar to this question) since it'll be piping in 204,000 entries from a database cursor :D

Writing the boiler plate for my own pattern seems way too heavy handed. There has to be something new in the pipeline replacing the balancing dispatcher.


Disorganised notes to self / train of thought.

What I am trying to solve:

Write with as little code as possible a producer-consumer system with 2 actor classes that saturates the processing power of a single machine. Also, do not dispatch all work from the consumer in one go as a) there is a lot of work (I don't know what the size limits of child mailboxes are) and b) the work has different shapes.

Approaches / Assumptions

I have not seen an example with a balanced dispatcher, so my expectations of what it does or how it can be used are most likely warped. A dispatcher seems very much a concept that is tied to the entire actor system, and documentation indicates requiring that all actors of a balanced dispatcher based actor system should be able to handle the same messages (or perhaps in other words be the same actor type).

If this is indeed the case the assumption doesn't really map neatly to prod-cons as the cons driver would have to be outside of the actor system. as either an actor in another system or a future based ask loop in the app startup. The actor types in balancing dispatcher could always have the logic and message types to become a prod but this would be a rather nasty hack. Or perhaps the actor system startup has a hook that can be used to pipe the message queue full (but again that doesn't seem like a nice way to do things). I'm coming to the conclusion that the balanced dispatcher is indeed nasty.

The above assumption is wrong, the end of the router documentation has this to say:

At first glance there seems to be an overlap between the BalancingDispatcher and Routers, but they complement each other. The balancing dispatcher is in charge of running the actors while the routers are in charge of deciding which message goes where. A router can also have children that span multiple actor systems, even remote ones, but a dispatcher lives inside a single actor system.

Which kind of solidifies the case for my question :D

Ok so child actors specified with a balancing dispatcher + a round robin router might do the trick. But where is the size of the shared mailbox attached (from general overview below, the optional parameters mailboxcapacity and mailbox-type seem to do it).

Links

There are three concepts in play here. The dispatcher, The router and the mailbox.

General overview

The latest documentation linked above does not seem to mention the balancing dispatcher being deprecated.

Community
  • 1
  • 1
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
  • Might I recommend a blog post I wrote about the work-pulling pattern? http://blog.goconspire.com/post/64901258135/akka-at-conspire-part-5-the-importance-of-pulling We had similar requirements and this is what we settled on. – Ryan Dec 07 '13 at 23:32
  • Ryan : Excellent, and many thanks. I have been looking all over the place for people writing about "REAL" use of akka since the documentation and books can be a bit basic. – Hassan Syed Dec 08 '13 at 23:42

1 Answers1

6

I'm the author of Effective Akka, and unfortunately, it appears that I was wrong about the BalancingDispatcher being deprecated - I went with what I thought was going to happen at the time the book was finished. It is going to change, though. From Roland Kuhn, head of the Akka team:

...we are not deprecating the BalancingDispatcher; we will, however, not offer it in its freely (mis)configurable form anymore, instead it will come as a Router of the Pool variety (i.e. managing its routees). If you want lowest jitter and lowest latency then pulling from a single queue is still the best thing I can think of.

Thanks!

jamie
  • 2,101
  • 1
  • 12
  • 7
  • 1
    Jamie, thanks I am glad they are 1) not deprecating the balancer and 2) rolling it into a router. Orchestrating new akka configurations is insanely complicated for newcomers Because of the lack of documentation and the nasty configuration library. – Hassan Syed Dec 08 '13 at 23:45