3

I have a couple of workers waiting to do some jobs. I see that in the PULL/PUSH pattern I need to give the workers the ip address (using the tcp protocol) of the client, so it can listen to requests from there. However, in my case I want to have a lot of clients as well, coming from different IPs with requests... So basically I dont really have a static IP to bind the worker to PULL from. Am I using the wrong pattern or is there a way to do it correctly?

j0k
  • 22,600
  • 28
  • 79
  • 90
Joel
  • 5,949
  • 12
  • 42
  • 58

1 Answers1

4

You should consider using the router-dealer pattern. Your router binds at 2 ends and it has a static IP. It pulls from the multiple clients that connect to it and pushes to the workers on the other end. You can use the ROUTER/DEALER socket types to make this or just use an extra bridge using PUSH/PULL sockets to connect the clients to the workers.

tapan
  • 1,776
  • 2
  • 18
  • 31
  • 1
    That 'extra' bridge for PUSH/PULL socket types in zmq is called a `STREAMER`. http://api.zeromq.org/2-2:zmq-device#toc5 – g19fanatic Aug 13 '12 at 12:02
  • 1
    Yes, the ``STREAMER`` really solves the problem and I found an excellent working example here: https://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/devices/streamer.html – Tregoreg Aug 19 '13 at 19:20
  • @Tregoreg Is `zmq.STREAMER` of Python the same as `ZMQ_STREAM` socket of the C API? – kakyo Nov 07 '19 at 02:07