以下是我在 linux 系统上处理 tcp 和打开文件的当前值:
$cat /proc/sys/fs/file-max # outputs 1,624,164.
$cat /proc/sys/net/ipv4/tcp_max_syn_backlog #outputs 1,048,576
$cat /proc/sys/net/core/somaxconn # output 65535
$ulimit -a # open files = 1,024,000, max user processes = 10,240
问题 2: 我还将 redis 中的超时设置为 0,tcp-keepalive 设置为 60,tcp-backlog 设置为 65535。我正在使用 predis,我将那里的超时设置为 0,read_write_timeout 设置为 -1。但是,我们会定期收到以下错误。
2015-10-28 11:24:14 406309 cron-web Error while reading line from the server. [tcp://10.0.0.1:6379]
2015-10-28 19:15:13 0 web-billing-3 Error while reading line from the server. [tcp://10.0.0.1:6379]
2015-10-28 19:56:58 0 web-billing-3 Operation timed out [tcp://10.0.0.1:6379]
2015-10-29 10:02:25 437257 web-billing-1 Error while reading line from the server. [tcp://10.0.0.1:6379]
2015-10-29 12:03:54 439897 cron-web Error while reading line from the server. [tcp://10.0.0.1:6379]
2015-10-29 15:06:23 443772 web-billing-3 Error while reading line from the server. [tcp://10.0.0.1:6379]
我已经尝试将超时 inroads 更改为 300,但仍然无效。 linux 系统参数也按照问题 1 中的说明设置。所有这些都无济于事。有什么建议吗?
最佳答案
似乎这种情况在使用 PRedis 之前就已经发生过,它可能是它使用连接的方式导致服务器上的 IP 连接跟踪过载。或者您的脚本启动了“太多”连接。无论哪种方式,如果是这种情况,您都可以很容易地弄清楚。
在 Redis 服务器上,运行 dmsg| grep conntrack
。如果您看到类似 ip_conntrack: table full, dropping packet
的消息,那么这就是问题所在。您可以按照 this article 中的步骤进行操作通过更改您的 /proc/sys/net/ipv4/ip_conntrack_max
设置来修复它以匹配/超过您在 /proc/sys/net/ipv4/netfilter/ip_conntrack_count< 中看到的峰值
.
最终虽然这可能属于 super 用户,因为它很可能是系统级问题。
编辑:
要确定并发连接,您需要查看 info clients
并查看当前连接数。您需要随着时间的推移对其进行跟踪以确定并发配置文件是什么,以便查看它是否可能是问题所在。显然,您运行的分辨率越细(即检查和存储的频率越高),您捕获并发峰值的机会就越大。
我真的怀疑问题出在 Predis,因为它有已知的连接管理问题。如果可以,尝试使用 phpredis 看它是否继续发生。
关于tcp - 从服务器读取行时 Redis 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33602394/