[temp@xigua ~]$ ss -s
Total: 83678 (kernel 0)
TCP: 84982 (estab 127, closed 84812, orphaned 0, synrecv 0, timewait 1485/0), ports 0
Transport Total IP IPv6
* 0 - -
RAW 0 0 0
UDP 4 3 1
TCP 170 168 2
INET 174 171 3
FRAG 0 0 0
这里可以看到 CLOSED 状态的socket 有8w+ (closed 84812), 同时查看某个 fpm :
[temp@xigua ~]$ ss -s $ lsof -p ${fpm-pid}|grep 'protocol: TCP'|wc -l
1043
fpm 进程一共有 8 0个, 所以几乎可以肯定全是 fpm 导致的上述占用过多 CLOSED socket, 主要是我不理解为啥 fpm
不释放这些 socket, CLOSED 状态下的 socket 不是应该转瞬就被系统回收了吗?
这些状态为 CLOSED 的 socket 仍然占用较多内存, 当超过 tcp 上限(cat /proc/sys/net/ipv4/tcp_mem)的时候会报错 : out of memory -- consider tuning tcp_mem
请问我需要怎么进一步解决呢?
P.S. 2019年2月26日17:53:34 进一步的信息补充 :
$ ls -l /proc/${pfm}/fd|wc -l
1059
cat /proc/net/sockstat
sockets: used 84442
TCP: inuse 168 orphan 0 tw 3052 alloc 84262 mem 84093
UDP: inuse 3 mem 1
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0
$ netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n
1 established)
1 Foreign
8 LISTEN
28 CLOSE_WAIT
138 ESTABLISHED
782 TIME_WAIT
pm.max_children = 80
pm.max_requests = 100000
$ cat /proc/net/sockstat
sockets: used 29901
TCP: inuse 168 orphan 0 tw 3618 alloc 29720 mem 29563
UDP: inuse 3 mem 1
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0
$ free -m
total used free shared buff/cache available
Mem: 7821 824 250 418 6746 6064
Swap: 511 98 413
$ cat /proc/net/sockstat
sockets: used 387
TCP: inuse 167 orphan 0 tw 3504 alloc 207 mem 42
UDP: inuse 3 mem 1
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0
$ lsof -p ${fpm-pid}|less
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 17699 temp 71u sock 0,7 0t0 552415632 protocol: TCP
php-fpm 17699 temp 72u sock 0,7 0t0 552428529 protocol: TCP
php-fpm 17699 temp 73u sock 0,7 0t0 552450479 protocol: TCP
php-fpm 17699 temp 74u sock 0,7 0t0 552462900 protocol: TCP
php-fpm 17699 temp 75u sock 0,7 0t0 552523600 protocol: TCP
php-fpm 17699 temp 76u sock 0,7 0t0 552542925 protocol: TCP
php-fpm 17699 temp 77u sock 0,7 0t0 552613133 protocol: TCP
php-fpm 17699 temp 78u sock 0,7 0t0 552639299 protocol: TCP
php-fpm 17699 temp 79u sock 0,7 0t0 552646395 protocol: TCP
php-fpm 17699 temp 80u sock 0,7 0t0 552659030 protocol: TCP
发现大量的 "protocol: TCP" 字样, 请教大家这是什么意思?为何不展示出 tcp 连接的双端ip, 端口信息而是省略成了"TCP"字样?
holdtom
绝地无双
森林海