1、html
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指令後設置與其匹配的值.
nginx
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 一次優化引起的血案.net
Reference: https://www.nginx.com/blog/tuning-nginx/日誌