zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

038_nginx backlog配置

2023-09-27 14:19:39 时间

一、

backlog=number
sets the backlog parameter in the listen() call that limits the maximum length for the queue of pending connections. By default, backlog is set to -1 on FreeBSD, DragonFly BSD, and macOS, and to 511 on other platforms.

(1)net.core.somaxconn参数:能够被nginx缓存队列的最大的连接数量,如何你的nginx遇到比较大的流量时,系统kernel日志messages中会出现这个值太小的报错,可以修改这个默认参数增大它的值.Notice:如何你设置的值大于512,在nginx listen指令后设置与其匹配的值.

cat /proc/sys/net/core/somaxconn    #系统默认值
65535

(2)net.core.netdev_max_backlog参数:被切换到CPU处理前被网卡缓存的速率包,根据网卡文档加大值可以提高性能.

cat /proc/sys/net/core/netdev_max_backlog
65535  

 其他优化及参考:

(1)https://www.04007.cn/article/323.html   nginx配置文件中listen后面的backlog配置

(2)https://huoding.com/2014/08/13/367    一次优化引发的血案

Reference: https://www.nginx.com/blog/tuning-nginx/