[zeromq-dev] Publisher/Subscriber concept

Martin Sustrik sustrik at 250bpm.com
Tue Apr 6 13:04:01 CEST 2010

Hi John,

> Where, by whom and how many, messages are accumulated? I am a bit
> puzzled by your answer as I was under the impression that, if there
> were no consumer available, an error would be raised? What is the
> case when the consumer is unable to keep up with the producer? Do the
> messages get 'paged'?

No you won't get error if there's no consumer. What happens in such case 
depends on the messaging pattern.

With publish/subscribe, messages are simply dropped if there are no 
listening consumers. I would liken it to a radio transmission. The 
transmitter is transmitting even if there's noone listening.

With request/reply and parallelised pipeline (a.k.a. "butterfly") the 
messages are queued and will be sent once there's a consumer available.

As for the queueing, there are many places where it happens. In case of 
simple TCP connection the data may be queued in sender's 0MQ queue, in 
senders TCP tx buffer, in NIC's outbound buffer, in packet queues within 
switches, in different places in routers, in receiver's NIC buffer, in 
receiver's TCP rx buffer, and in receiver's 0MQ queue.

If consumer is not able to keep up with sender, all these queues are 
gradually filling. Once the limits are reached each device acts in 
different way. However, the most common behaviour is simply dropping 
packets. TCP will use its congestion control algorithms. 0MQ itself 
behaves depending on the messaging pattern: for PUB/SUB it will drop 
messages, for REQ/REP it will block.


More information about the zeromq-dev mailing list