我们正在使用Redis消息总线,并使用通道来处理消息。但是,如果我们的应用程序部署在多个实例中,那么请求和响应将传递到所有实例。为了避免这种情况,以下哪种方法更好?
任何建议都会受到赞赏
答案 0 :(得分:0)
此处的限制因素是同一频道的订户数量。这样,通道数可能会很大。因此,您可以相应地选择粒度。在此处阅读更多信息:
https://groups.google.com/forum/#!topic/redis-db/R09u__3Jzfk
All the complexity on the end is on the PUBLISH command, that performs
an 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.