使用 zmq(zeromq) 检测慢速读取器

发布于 2024-08-02 12:02:21 字数 268 浏览 4 评论 0 原文

我正在尝试替换一个小型的国产消息系统,并且正在使用 zmq 。 我需要检测缓慢的读取器,并启动/断开它们 - 缓慢的读取器几乎意味着队列大小高于特定阈值的特定消费者。

到目前为止,如果其中一个消费者有点慢(很公平),zmq 似乎会阻止每个消费者 - 但是 我找不到任何方法来检测潜在的慢速消费者。任何人有任何经验 zmq 是否以及如何实现这一点 - 或者是否有任何其他无代理消息传递系统值得推荐?

I'm trying to replace a small homegrown messaging system, and are playing around a bit with zmq .
I'll be needing to detect slow readers, and boot/disconnect them - slow readers pretty much meaning a particular consumer whos queue size is above a certain threshold.

So far it seems zmq blocks every consumer if one of them is a bit slow (fair enough) - but
I can't find any way to detect a potential slow consumer. Anyone have any experience with
wether and how this is possible with zmq - or have any other broker-less messaging system to recccommend ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰魂雪魄 2024-08-09 12:02:21

从 Zeromq-2.0.7 开始,您可以在 ZMQ_PUB 套接字上设置 ZMQ_HWM 选项来控制订阅者可以排队的最大消息数。一旦达到高水位线,发往该订阅者的所有其他消息都将被丢弃,直到队列大小回落到高水位线以下。这限制了专用于所谓的慢速读取器的内存量。

但是,由于 ZeroMQ 库公开套接字而不是客户端,因此您无法在不修改库本身的情况下识别并强制断开不需要的客户端。

As of zeromq-2.0.7, you can set the ZMQ_HWM option on a ZMQ_PUB socket to control the maximum number of messages that can be queued for a subscriber. Once the high-water mark has been reached, all further messages destined for that subscriber will be dropped until the queue size drops back below the high-water mark. This limits the amount of memory dedicated to what you call a slow reader.

However, because the ZeroMQ library exposes sockets, not clients, there is no way for you to identify and forcibly disconnect unwanted clients without modifying the library itself.

痴者 2024-08-09 12:02:21

ZeroMq 指南中有一节与此相关,它建议实现一种名为“自杀蜗牛模式”。

基本上,它扭转了依赖性,并试图通过为缓慢的订阅者提供一种检测他们是否已成为缓慢阅读者的方法来说服他们断开连接/自杀。

There is a section in the ZeroMq Guide regarding this, it suggests implementing a pattern the call the "Suicidal Snail Pattern".

Basically, it reverses the dependency and tries to convince slow subscribers to disconnect/kill themselves by giving them a way to detect if they have become slow readers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文