Phi*_*ost 17 linux networking monitoring
我有一个假设:有时 TCP 连接到达的速度比我的服务器更快accept()。他们排队直到队列溢出,然后出现问题。
我如何确认这正在发生?
我可以监控接受队列的长度或溢出的数量吗?有没有暴露在某个地方的柜台?
lfm*_*noz 10
要检查您的队列是否溢出,请使用 netstat 或 nstat
[centos ~]$ nstat -az | grep -i listen
TcpExtListenOverflows 3518352 0.0
TcpExtListenDrops 3518388 0.0
TcpExtTCPFastOpenListenOverflow 0 0.0
[centos ~]$ netstat -s | grep -i LISTEN
3518352 times the listen queue of a socket overflowed
3518388 SYNs to LISTEN sockets dropped
Run Code Online (Sandbox Code Playgroud)
参考:https : //perfchron.com/2015/12/26/investigating-linux-network-issues-with-netstat-and-nstat/
要监视队列大小,请使用 ss 命令并查找 SYN-RECV 套接字。
$ ss -n state syn-recv sport = :80 | wc -l
119
Run Code Online (Sandbox Code Playgroud)
参考:https : //blog.cloudflare.com/syn-packet-handling-in-the-wild/