与往常一样,您需要针对自己的用例对此类事情进行基准测试-
无法提供一般性建议。您可能需要增加系统范围内或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/*}以及您的redismaxclients设置,然后是基准,基准,基准!



