【问题标题】:One redis channel per user?每个用户一个redis通道?
【发布时间】:2014-08-16 20:52:51
【问题描述】:

我试图理解这个使用 Gevent 和 Redis pub/sub 的 socket.io 代码。显然subscribe 方法在频道上等待消息。

我可以拥有(数万个)频道,一个频道每个用于向一位用户推送通知和聊天吗?频道是为此而生的吗?

def _sub_listener(socketio, chan):
    """
    This is the method that will block and listen
    for new messages to be published to redis, since
    we are using coroutines this method can block on
    listen() without interrupting the rest of the site
    """
        red = Redis(REDIS_HOST)
        red.subscribe(chan)

        for i in red.listen():
            socketio.send({'message': i})

【问题讨论】:

    标签: redis socket.io


    【解决方案1】:

    我也在寻找同样的东西。通过搜索,我发现论坛说 Redis 可以非常有效地处理多达 10k 个频道。但是如果频道超过 10k 会发生什么,我还没有得到任何绝对的答案。

    我目前正在尝试使用共享频道。 Here 是一个使用共享通道的示例算法/实现。

    【讨论】:

      猜你喜欢
      • 2016-12-09
      • 1970-01-01
      • 2019-07-15
      • 2023-03-27
      • 2014-01-13
      • 2016-10-22
      • 2016-09-25
      • 1970-01-01
      • 2020-08-31
      相关资源
      最近更新 更多