ZMQ sockets with custom load-balancing

被刻印的时光 ゝ 提交于 2019-12-12 20:05:37

问题


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?

回答1:


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.



来源:https://stackoverflow.com/questions/20649709/zmq-sockets-with-custom-load-balancing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!