文章15 | 阅读 4764 | 点赞0
worker_processes与worker_connections 设置好合适大小,可以提示nginx处理性能,非常重要。
原作者的话:
As a general rule you need the only worker with large number of worker_connections, say 10,000 or 20,000.
However, if nginx does CPU-intensive work as SSL or gzipping and you have 2 or more CPU, then you may
set worker_processes to be equal to CPU number.
Besides, if you serve many static files and the total size of the files is bigger than memory, then you may
increase worker_processes to utilize a full disk bandwidth.
Igor Sysoev
翻译:
一般一个进程足够了,你可以把连接数设得很大。(worker_processes: 1,worker_connections: 10,000)
如果有SSL、gzip这些比较消耗CPU的工作,而且是多核CPU的话,可以设为和CPU的数量一样。(worker_processes: CPU核心数)
或者要处理很多很多的小文件,而且文件总大小比内存大很多的时候,也可以把进程数增加,以充分利用IO带宽(主要似乎是IO操作有block)
数字越大,能同时处理的连接越多
worker_processes 2;
worker_rlimit_nofile 65535;
#pid logs/nginx.pid;
events {
worker_connections 65535;
}
通过 ps -elf | grep nginx 找到 nginx 的worker进程ID
通过 cat /proc/31613/limits 查看,其中2291是worker进程ID,请注意其中的Max open files
从上面的分析可以看出nginx占用内存小,处理性能高,通过提高服务器的配置,Nginx可以应对更大的连接数
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://zhuyu.blog.csdn.net/article/details/90714429
内容来源于网络,如有侵权,请联系作者删除!