[zeromq-dev] Publish / Subscribe vs Multicast

gonzalo diethelm gdiethelm at dcv.cl
Mon Feb 15 19:00:46 CET 2010

Hi Martin,

> > 1. The distributor has the logic to decide which worker should get a
> > specific message, and sends it directly to it. This means: the
> > distributor knows how many workers there are (in order to evenly
> > distribute messages); it knows what workers are not responding; it
> > made aware of new workers. I agree in this scenario Multicast it not
> > needed, nor is PubSub.
> >
> > 2. The distributor sends every message to all workers, and they
> > whether to ignore it or if they are the ones to process it. This
> > the distributor doesn't need any special knowledge about the
workers; it
> > should use PubSub or Multicast; the workers need logic to determine
> > whether to process or ignore the message, and this logic would most
> > likely require knowing about all the other workers and their state.
> >
> > What do you think?
> The former is better IMO. In the latter case you would have to handle
> communication between individual workers which turns out to be pretty
> complex, especially when they become mutually inaccessible.

I agree, as long as the first case allows for building in the logic to
handle a (possibly) dynamic number of workers, stalled workers, etc.

> > Maybe I should have described first my ideal scenario. I would love
> > be able to add workers at will, or even kill them at will, without
> > having to restart the distributor or any current workers. This is
> > strictly hot-hot failover, but you might call it "dynamic load
> > distribution". That is why I think sending the messages to all
> > might make sense.
> I would definitely use ZMQ_UPSTREAM and ZMQ_DOWNSTREM sockets. Hava a
> look at the following article:
> http://www.zeromq.org/tutorials:butterfly
> (The code samples use old API so just ignore them.)
> Is that what you are aiming for?

Sweet! Yes, that is the scenario I am researching. However, I could not
find that tutorial anywhere in the downloaded source code (for Windows).
Do I need to get it from the repo? Or perhaps it is not included anymore
(since you mention an old API)?

> > In my pipeline, I could also do this:
> >
> > 1. The distributor receives a request for work.
> > 2. It creates a unique tag for it and sends it, together with
> > time, to the final program in the pipeline (let's call it the
> > 3. It then passes the request to the first stage in the pipeline
(one of
> > N workers for this stage).
> > 4. It moves from stage to stage, where each stage has Ni workers.
> > 5. The final stage passes a notification to the checker including
> > request id and current time.
> >
> > Strict pipeline, no request-reply (so I can fire and forget), still
> > know when requests end, how long they take and even take measures
> > requests taking too long.
> Yes. Exactly. In pipelined scenario the tag should be a sequence
> That way final receiver can identify holes in the sequence (caused by
> crashed workers or crashed distributors) and notify the original
> about the failure.

Yes. Sort of like TCP/IP does it.

> >> In case you would like to give a hand with the implementation, let
> >> know.
> >
> > Would love too. I still am at the beginning stages of wrapping my
> > around 0mq, so please give me some time.
> Sure. Take your time!

I'm slowly gearing up to it. Thanks for all the help.

Gonzalo Diethelm

Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 

More information about the zeromq-dev mailing list