[zeromq-dev] LRU broker queue in intuitive way on 3.0

Pieter Hintjens ph at imatix.com
Tue Apr 5 00:30:06 CEST 2011


On Tue, Apr 5, 2011 at 12:16 AM, Paul Colomiets <tailhook at yandex.ru> wrote:

> There are two patterns in the guide for request/reply broker. One
> with using XREQ on router and REP on worker. And the other is
> based on XREP on router REQ on worker. The problem is that
> first is being obvious but basically does not work. The latter
> is counter-intuitive and code is much more comples but works much
> better.

This is a good point. Having to use a REQ socket for workers is weird.
It works, but it's surprising, which is a bad sign.

In fact the LRU mechanism could be done by the socket layer, because
it's completely generic. It would IMO be a new socket pattern:

* BOSS socket, which organizes a group of workers, and
* WORKER socket, which takes orders from a BOSS socket

The BOSS socket keeps a list of ready workers, which signal presence
to the BOSS socket, when they connect, and when they reply to a
request. They work synchronously, and look just like REP sockets to
applications. They could fan-in from multiple BOSS sockets. The BOSS
socket will queue messages until it can send them, and will return
replies that can be sent back up to clients.

Then a LRU queue device has a ROUTER socket to talk to clients, and a
BOSS socket to talk to workers, and becomes a simple read/write device
between the two.

-Pieter



More information about the zeromq-dev mailing list