具有自定义负载平衡功能的ZMQ插座 [英] ZMQ sockets with custom load-balancing

查看:116
本文介绍了具有自定义负载平衡功能的ZMQ插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了ZMQ PUSH/PULL套接字,尽管我非常喜欢简单性(特别是与我现在正在通过UDP套接字在系统中实现的自定义碎片/ack相比),但我还是希望拥有自定义负载平衡功能,而不是ZMQ PUSH/PULL套接字正在使用的幼稚循环机制(我相信).

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.

我是ZQM的新手,不确定如何使用ZMQ套接字实现它,甚至根本不可能实现.我理想的情况是,服务中的PUSH套接字(或某些其他套接字类型)(基于消息等)确定将消息发送到哪台计算机.

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.

所以我的问题是:

  1. 这可能吗?
  2. 如果是这样,哪种ZMQ模式最适合?
  3. 如何使用这些插槽?

推荐答案

如果要使用自定义路由,则必须使用ROUTER套接字,然后使用基于IDENTITY的路由. 指南中有一个示例说明了如何构建使用ROUTER套接字进行简单的LRU路由(即行为与PUSH相同).您只需要编写自己的逻辑来确定哪个工作人员IDENTITY可以获取每条消息.

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.

这篇关于具有自定义负载平衡功能的ZMQ插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆