标签:max clients Redis number 192.168 limit
问题描述
生产环境上突然出现数据中断的情况,分析日志发现应用连接Redis出现“max number of clients reached”的异常。那么问题很明显了,某个应用将Redis的连接占满了。
分析方法
- 第一步,先分析Redis.conf文件,确认配置的连接数为多少,我们系统采用的默认值10000。
################################### CLIENTS ####################################
# 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 to 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
- 第二步,根据业务场景分析,系统的并发数远远小于10000,因此初步判断是某应用在使用连接后未及时释放导致。通过下列命令来分析目前连接的情况:
redis-cli -p 6379 -axxxx client list |wc -l
发现连接数已经几乎占满,因此进一步分析是通过连接的IP分布情况来确定出问题的应用:
redis-cli -p 6379 -axxxx client list |awk '{print $2}'|awk -F '=' '{print $2}'|awk -F ':' '{print $1}'|sort | uniq -c
1 192.168.1.4
1733 192.168.1.55
848 192.168.1.66
919 192.168.1.77
1857 192.168.1.88
- 最终分析发现链接数占用多的都来自同一个服务,此应用在订阅消息后,针对每个分区的消息都创建了一个Redis连接池,导致连接数暴增。
标签:max,clients,Redis,number,192.168,limit 来源: https://blog.csdn.net/longchi176/article/details/115347637
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。