我在 ZeroMQ 上最多可以拥有多少主题?

What's the max of topics I can have on ZeroMQ?

我是 ZeroMQ 的新手(到目前为止我一直在使用 SQS)。

我想构建一个系统,每次用户登录时,他们都会订阅一个队列。订阅该队列的所有用户只对发送给他们的消息感兴趣。

我阅读了主题匹配。看来我可以创建这样的模式:

development.player.234345345
development.player.453423423
integration.player.345354664

而且,每个工作人员(用户)都可以订阅队列并只收听他们匹配的主题。即开发环境中的玩家234345345只会订阅主题为development.player.234345345

的消息

这是真的吗?

如果是这样,ZeroMQ 中的后果是什么?

主题匹配的数量有限制吗?

ZeroMQ 有一个非常详细的页面介绍如何 internals of topic matching works。看起来您可以拥有任意数量的主题,但是主题 匹配 会产生运行时成本。它应该非常快:

We believe that application of the above algorithms can give a system that will be able to match or filter a single message in the range of nanoseconds or couple of microseconds even it the case of large amount of different topics and subscriptions.

但是,您需要注意一些注意事项:

The inverted bitmap technique thus works by pre-indexing a set of searchable items so that a search request can be resolved with a minimal number of operations.

It is efficient if and only if the set of searchable items is relatively stable with respect to the number of search requests. Otherwise the cost of re-indexing is excessive.

总之,只要不经常换订阅,至少几千个话题应该可以做到。

答:可以

最大。数字?更难的部分...

可能想阅读 Martin SUSTRIK 的 post:

虽然 ZeroMQ 是独立发展的,但 ZeroMQ 之父 Martin post就此主题介绍了一些有趣的事实 here, with some further details and design view discussion derrogated here

Efficient Subscription Matching

In ZeroMQ, simple tries are used to store and match PUB/SUB subscriptions. The subscription mechanism was intended for up to 10,000 subscriptions where simple trie works well. However, there are users who use as much as 150,000,000 subscriptions. In such cases there's a need for a more efficient data structure.

值得一读以估计安全区的位置。

同样值得一提的是,并非所有 ZeroMQ 版本的行为方式都相同。

最近API使用PUB端的话题过滤,之前的所有版本都不是自动的,其中SUB端的过滤被使用了。将其转化为所有网络传输,如果所有消息,无论其最终命运如何,都广播到所有 SUB-s,只是为了意识到只有一个(您的用例中的用户)会匹配,其余的都会匹配由于主题过滤器不匹配,丢弃消息。

因此,您所有的用例都应该考虑到不同的 ZeroMQ 版本(包括不同的非本地语言绑定和包装器)可能 在同一个游乐场相遇合作

总之,ZeroMQ是一个很棒的工具,nanomsg也是近年值得关注和挑战的。