0
点赞
收藏
分享

微信扫一扫

Linux net.core.somaxconn 参数详解


net.core.somaxconn

Linux 操作系统全局参数,每个 TCP 监听端口的队列长度。在 CentOS/RHEL 7.9 中,默认值为128,对于高并发场景都建议调大该值。

1.官方描述

​​The Linux Kernel​​​ somaxconn - INTEGER
Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 4096. (Was 128 before linux-5.4) See also tcp_max_syn_backlog for additional tuning for TCP sockets.

​​取值范围:​​

  • In RHEL 6 & RHEL 7, the sk_max_ack_backlog field of the sock
    structure is defined as unsigned short which limits the values to 16
    bits whose maximum value is 65535.
  • In RHEL 8, sk_max_ack_backlog
    field of the sock structure is defined as u32 which limits the values
    to 32 bits whose maximum value is 2147483647.

2.不同应用的配置建议

2.1.​​Oracle WebLogic Server​​

  • Number of clients: Set somaxconn should be set to at least 1024 to
    allow for a large number of client server connections.
  • Number of queued packets: Set netdev_max_backlog to at least 32768 to minimize packet loss.

2.2.​​ZooKeeper​​

On linux, below parameter :

net.core.somaxconn

needs to be larger than above “clientPortBacklog” to correctly configure listen socket backlog

2.3.​​TiDB​​

检查各项内核参数的值:

net.core.somaxconn: 32768

2.4.​​Nginx​​

Increase the value of the net.core.somaxconn kernel parameter from its default value (128) to a value high enough for a large burst of traffic. In this example, it’s increased to 4096.

3.配置方法

3.1.临时生效

sysctl -w net.core.somaxconn=10240

3.2.永久生效

echo "net.core.somaxconn = 10240" >>/etc/sysctl.conf
sysctl -p


举报

相关推荐

0 条评论