[zeromq-dev] loadbalancing problem?

Martin Sustrik sustrik at 250bpm.com
Wed Oct 20 09:32:12 CEST 2010


Hi Sven,
>
> Conclusion: (correct me, if I'm wrong ;o) the balancing algorhythm 
> does a round robin on all CONNECTED workers instead of doing a round 
> robin on currently RECV()ING workers.
>
> Since I'm not that deed in the guts of ZMQ, I'd like to ask: is it 
> very complicated to rewrite the XREQ socket (the worker side in the 
> queue device) to balance the requests only to workers, that are really 
> idle and currently recv()ing?

Actually, it's impossible. When you are sending the message you have no 
guarantee that the receiver will be still recv()ing when the message 
arrives.

As for your design, you have a distributed deadlock in your app. You 
have to fix that. Even if 0MQ was able to send only to sockets that are 
actually recv()ing at the time, it wouldn't solve your problem.

Imagine there are 5 nested calls of "service" instead of 2 as in your 
example. First one would block service instance 1, second one would 
block instance 2 etc. The fifth nested call would deadlock :(

In short, if you want to invoke services in recursive way you have to 
ensure that the instance when performing a request, doesn't block other 
requests to happen in the same time.

Mostly, the above is implemented by no state in the service, all state 
being packed in the messages.

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101020/cecb026a/attachment.htm>


More information about the zeromq-dev mailing list