2

I looked at ZMQ PUSH/PULL sockets and even though I quite like the simplicity (especially compared to custom fragmentation/ack I am implementing right now in a system over UDP sockets), I would like to have custom load balancing instead of the naive round-robin (I believe) that ZMQ PUSH/PULL sockets are using.

I am new to ZQM and not sure how I can implement it using ZMQ sockets and if it's even possible at all. What I would ideally like is, the serving PUSH socket (or some other socket type) determines (based on the messages etc.) which machine to send the message to.

So my questions are:

  1. Is this possible?
  2. If so, what ZMQ pattern would work best for it?
  3. How can I use those sockets?
mmtauqir
  • 8,499
  • 9
  • 34
  • 42

1 Answers1

3

If you want to have custom routing, you have to use ROUTER sockets, and then use IDENTITY-based routing. There is an example in the Guide illustrating how to build simple LRU routing with a ROUTER socket (i.e. behaves the same as PUSH). You would just need to write your own logic for deciding which worker IDENTITY gets each message.

minrk
  • 37,545
  • 9
  • 92
  • 87
  • So let's say I have one "master" sending off work to a number of worker nodes ... I would have both the ROUTER and the "client" REQ socket(s) on the same node right? And the load-balancer would just pick the appropriate worker node? – mmtauqir Dec 18 '13 at 05:24
  • @mtahmed No, the server is ROUTER, the workers (clients) are REQ, or preferably async DEALERs, and they reside on separate nodes, not the same node. – raffian Dec 18 '13 at 06:27
  • 1
    You can have them wherever makes the most sense for you, zmq doesn't care. If your workers are on more than one node, then the load balancer can't be on the same node as all of your workers. – minrk Dec 18 '13 at 19:30