大网数据广告活动
服务器运维问答

How do I tell how close I'm getting to somaxconn?

· 52CE 我爱测

The sysctl option net.core.somaxconn defaults to 128 (on our systems) but can be raised. What exactly is this limit measuring and capping? How do I find out how close I am to the limit? Context: I had a problem recently that appe…

问题原文

原帖链接 · Andrew · CC BY-SA 3.0

The sysctl option net.core.somaxconn defaults to 128 (on our systems) but can be raised.

  1. What exactly is this limit measuring and capping?

  2. How do I find out how close I am to the limit?

Context: I had a problem recently that appeared to be corrected by raising this limit. The problem was intermittent, so I don't trust that it is really fixed. I would like to find out if the current number of [whatever this setting caps] is greater than the previous maximum limit of 128.

已采纳解答

原帖链接 · miken32 · CC BY-SA 4.0

somaxconn determines the maximum number of backlogged connections allowed for each TCP port on the system. Increasing it (recommended for servers) can prevent "connection refused" messages, but it can result in slow connections if the server can't handle the increased load.

You can check the current backlog with netstat -ant | grep -c SYN_REC according to this page. It will count how many connections are in the "SYN received" state, meaning the system has received a SYN packet (connection request) but hasn't acknowledged it yet.

If your system has ss installed, you can also use ss -s to display a summary of connections. Look for synrecv in the output, or ss -s | grep -Po '(?<=synrecv )\d+(?=,)' to just print the number.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-08-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。