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

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

Leave a Comment