difference between pub-sub and push-pull pattern in zeroMq

Bhuvan picture Bhuvan · Jul 23, 2013 · Viewed 22k times · Source

This two images are from http://zguide.zeromq.org/page:all.

What is the difference between this two pattern if we ignore sink in push-pull pattern ? Is there a difference in how a message gets transfer, if yes what is the difference ?

Answer

SteveLove picture SteveLove · Jul 23, 2013

The difference is that a PUB socket sends the same message to all subscribers, whereas PUSH does a round-robin amongst all its connected PULL sockets.

In your example, if you send just a single message from the root, then all the subscribers will receive it (barring slow subscribers, etc.) but only 1 worker.

The pub/sub pattern is used for wide message distribution according to topics. The push/pull pattern is really a pipelining mechanism. Your push/pull example seems to be attempting to do load-balancing, which is fine, but req/rep might be better suited to that due to other issues.

It looks like the "issues" here are described in the same part of the 0MQ guide you got the image from : push/pull ventilator example