Redis PubSub订阅机制如何工作?
我想创建一个发布-订阅基础结构,其中每个订阅者都将收听多个(例如100k)频道。
我认为可以将Redis
PubSub用于此目的,但是我不确定在这里订阅数千个频道是否是最佳实践。为了回答这个问题,我想知道Redis中的订阅机制在后台如何工作。
另一种选择是为每个订户创建一个频道,并在两者之间放置一些组件,该组件将获取所有消息并将其发布到相关的频道。
还有其他想法吗?
回答:
Salvatore /
Redis的创建者已在此处回答:https :
//groups.google.com/forum/#!topic /redis-
db/R09u__3Jzfk
All the complexity on the end is on the PUBLISH command, that performsan amount of work that is proportional to:
a) The number of clients receiving the message.
b) The number of clients subscribed to a pattern, even if they'll not
match the message.
This means that if you have N clients subscribed to 100000 different
channels, everything will be super fast.
If you have instead 10000 clients subscribed to the same channel,
PUBLISH commands against this channel will be slow, and take maybe a
few milliseconds (not sure about the actual time taken). Since we have
to send the same message to everybody.
以上是 Redis PubSub订阅机制如何工作? 的全部内容, 来源链接: utcz.com/qa/420637.html