redis - 在redis消息总线中为每个用户创建一个 channel 是一个好习惯吗

标签 redis message-queue stackexchange.redis azure-redis-cache message-bus

我们正在使用 Redis 消息总线并使用 channel 处理消息。但是如果我们的应用程序部署在多个实例中,那么请求和响应将传递给所有实例。为了避免这种情况,以下哪种方法更好?

  1. 为应用程序的每个实例创建一个 channel
  2. 为每个用户创建一个 channel

任何建议将不胜感激

最佳答案

此处的限制因素是同一 channel 的订阅者数量。 channel 的数量可能很大。所以你可以相应地选择粒度。在这里阅读更多内容:

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.

之前问过类似的问题:How does Redis PubSub subscribe mechanism works?

关于redis - 在redis消息总线中为每个用户创建一个 channel 是一个好习惯吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54804050/

相关文章:

redis - Heroku 崩溃(似乎是 Sidekiq/Redis )

locking - 更新 Redis 键/值时获取锁

django - 使用 MongoDB 作为 Celery 的消息队列

c# - 将 String[] 数组转换为 RedisKey[] 数组

redis - 处理 Azure Redis 缓存异常

redis - cas redis 票证登记处

python - 将所有 python-rom 对象放入列表中

Azure 服务总线,使用过滤器将大消息组装成较小的消息

无法创建 posix 消息队列

c# - 如何使用 StackExchange.Redis 存储未知类型的项目?