首页/系统/Linux 内核与性能调优速查/net.core.rmem_max / wmem_max 套接字缓冲上限
sysctl 内核参数72 条

net.core.rmem_max / wmem_max 套接字缓冲上限

单个套接字接收/发送缓冲区的硬上限(默认各 212992 字节);应用 setsockopt 与自动调优都受它封顶,长肥管道场景需要提高。

参数net.core.rmem_max、net.core.wmem_max
默认值212992 字节(208 KiB)
约束对象单 socket 缓冲区峰值

查看与调整

查看与调整
sysctl net.core.rmem_max net.core.wmem_max
sysctl -w net.core.rmem_max=16777216 net.core.wmem_max=16777216
改大只放宽上限,实际每连接缓冲仍由 tcp_rmem/tcp_wmem 自动调优与应用 setsockopt 决定。

易错点

  • 只改 max 不核对 tcp_rmem/tcp_wmem 上限会造成认知偏差:自动调优封顶取两者中的小值
  • 缓冲区越大内存占用越高,高连接数服务需按 连接数×单连接缓冲 估算内存增量

数据来源与参考

  • Linux 内核 Documentation/admin-guide/sysctl/net.rst
  • man 7 socket(SO_RCVBUF/SO_SNDBUF)
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌