确认与量化
确认与量化
curl -sS -o /dev/null --connect-timeout 3 http://10.0.0.5:80/; echo "rc=$?"
ss -s | grep -i timewait
ss -Htan '( dport = :80 or dport = :443 )' | wc -l
cat /proc/net/sockstat | grep -i tcp
sysctl net.ipv4.ip_local_port_range| 报错 | bind: Cannot assign requested address(EADDRNOTAVAIL) |
|---|---|
| 资源 | ip_local_port_range 定义的本地端口池,默认约 2.8 万 |
| 缓解 | tcp_tw_reuse=1、扩大端口范围、改长连接/连接池 |
| 本质 | 只有到同一目标四元组的连接才真正争抢端口 |
判定方法:同时看到 TW 数量接近端口池上限、且报错集中在高频外连的进程,即可确认;否则要排查是否 fd 或内存不足导致 bind 失败。