Linux:proc/net/sockstat tcp mem越来越大 [英] Linux: proc/net/sockstat tcp mem more and more larger

查看:42
本文介绍了Linux:proc/net/sockstat tcp mem越来越大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我们的系统通过/proc/net/sockstat发现hang和tcp mem越来越大.当出现挂起时,将打印:

Now, our system find hang and tcp mem more and more larger through /proc/net/sockstat. when hang appear, will print :

"tcp:太多孤立的套接字"

"tcp:too many of orphaned sockets"

sockstat,我们知道socket很少,但消耗1500页内存,为什么?

From sockstat, we know there are few socket, but consumes 1500 page mem, why ?

所以我有两个问题:

  1. 如何知道哪个进程消耗了 tcp socket 内存?
  2. 如何避免tcp:too many of orphaned sockets"?

(1)

~ # cat /proc/net/sockstat

套接字:使用了 56 个

sockets: used 56

TCP: inuse 6 orphan 0 tw 1 alloc 8 mem 1510

TCP: inuse 6 orphan 0 tw 1 alloc 8 mem 1510

UDP: inuse 8 mem 6

UDP: inuse 8 mem 6

UDPLITE:正在使用 0

UDPLITE: inuse 0

RAW:使用中 4

FRAG:正在使用 0 内存 0

FRAG: inuse 0 memory 0

(2)

~ # cat /proc/sys/net/ipv4/tcp_mem

900 1200 1800

900 1200 1800

~ # cat /proc/sys/net/ipv4/tcp_rmem

4096 87380 87380

4096 87380 87380

~ # cat /proc/sys/net/ipv4/tcp_wmem

4096 16384 65536

4096 16384 65536

推荐答案

对于 #1,sockets 的内存消耗是总和

For #1, memory consumption for sockets is the sum of

  • 套接字描述符
  • 内核发送队列(等待 NIC 发送的内容)
  • 内核接收队列(已接收但尚未被用户空间读取的内容).

(这篇文章是相关的)

对于 /proc/net/sockstat 的示例输出,套接字的数量很少,因此请检查其发送/接收队列的大小.您可以使用诸如 netstat -tanpss -tp 之类的命令来执行此操作.请记住,发送和接收缓冲区大小显示为例如ss -m 是最大值(受 tcp_rmem 和 `tcp_wmem> 约束),而不是当前分配的值.

For your example output from /proc/net/sockstat, the number of sockets is small, so check the size of their send/receive queues. You can do this using commands like netstat -tanp or ss -tp. Keep in mind that send and receive buffer sizes displayed with e.g. ss -m are maximum values (constrained with tcp_rmem and `tcp_wmem), not the currently allocated values.

对于 #2,这篇文章 解释了太多孤儿套接字"是由于孤儿数量增加超过 /proc/sys/net/ipv4/tcp_max_orphans 中的值引起的,尽管某些种类的坏"套接字受到的惩罚超过其他人,因此即使您比限制低 2 倍或 4 倍,您也可能会遇到错误.

For #2, this post explains that the "too many orphan socket" is caused by the number of orphans increasing past the value in /proc/sys/net/ipv4/tcp_max_orphans, though some kinds of "bad" sockets are penalized more than others, so you could hit the error even if you're 2x or 4x below the limit.

这篇关于Linux:proc/net/sockstat tcp mem越来越大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆