问题原文
原帖链接 · Andrew · CC BY-SA 3.0
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 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
