栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何为即时消息系统设计Redis发布/订阅?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何为即时消息系统设计Redis发布/订阅?

与往常一样,您需要针对自己的用例对此类事情进行基准测试-
无法提供一般性建议。您可能需要增加系统范围内或redis用户的最大打开文件数。当然,这也适用于运行Web服务器的用户。

也就是说,您应该确保在用户离开时收听

socket.on('disconnect')
quit()
Redis订阅者。您可能还想知道socket.io具有一个redis后端,该后端利用了redis
pub / sub,还具有room的概念,因此您可以通过使用它来节省一些麻烦,因为您已经依赖于socket .io。

编辑: 快速检查后,我从991个订户后从Redis收到此错误消息:

Ready check failed: Error: Error: ERR max number of clients reached

这是默认值

redis.conf

# Set the max number of connected clients at the same time. By default# this limit is set to 10000 clients, however if the Redis server is not# able ot configure the process file limit to allow for the specified limit# the max number of allowed clients is set to the current file limit# minus 32 (as Redis reserves a few file descriptors for internal uses).## once the limit is reached Redis will close all the new connections sending# an error 'max number of clients reached'.## maxclients 10000

我的系统(Ubuntu
11.11)的默认

nofile
限制为1024,因此我的快速测试应该在连接了992个客户端之后失败,这在测试中似乎是正确的(我也有一个发布者客户端)。我的建议是检查您的
nofile
限制(在我的系统上,
/etc/security/limits.{conf,d/*}
以及您的redis
maxclients
设置,然后是基准,基准,基准!



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/387378.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号