【问题标题】:Redis error while reading line from the server从服务器读取行时 Redis 错误
【发布时间】:2016-02-09 16:50:17
【问题描述】:

以下是我在 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

第二季度: 我还将 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]

我尝试将超时时间更改为 300,但仍然无法正常工作。 linux 系统参数的设置也如问题 1 所示。所有这些都无济于事。请问有什么建议吗?

【问题讨论】:

    标签: tcp redis predis


    【解决方案1】:

    这种情况似乎在 w/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 中看到的峰值来修复它。

    虽然这个可能最终属于超级用户,因为它很可能是系统级问题。

    编辑: 要确定并发连接,您需要查看info clients 并查看当前连接数。您需要随着时间的推移对其进行跟踪以确定并发配置文件是什么,以便查看它是否可能是问题所在。显然,您运行的分辨率越精细(即检查和存储的频率越高),您捕获并发峰值的机会就越大。

    我真的怀疑问题出在 Predis 上,因为它已知有连接管理问题。如果可以的话,试试用phpredis看看会不会继续出现。

    【讨论】:

    • 我得到的输出是 [11351916.175115] nf_conntrack 版本 0.5.0(16384 个桶,最大 65536 个)。在我的 redis 实例上,当我运行“redis-cli info stats”时,我有超过 1100 万个 total_connections_received。我的redis timeout设置为0,tcp-backlog设置为65535,tcp-keepalive设置为60。
    • total_connections_received stat 只是一个计数器,它不包括并发连接数,这可能是您需要发现的更多内容。
    • 我也在跟踪并发连接。但我想得到一些反馈,关于输出 {{{[11351916.175115] nf_conntrack version 0.5.0 (16384 buckets, 65536 max)}}} 是否意味着有问题,因为我没有得到类似 {{{ip_conntrack:表已满,丢包}}}
    猜你喜欢
    • 2020-10-17
    • 2018-07-20
    • 2021-10-24
    • 2017-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2012-07-31
    相关资源
    最近更新 更多