便便代码人生

关注技术, 偶尔动动手

[译]nginx的worker_processes设为多少才合适?

Posted by bianbian on 2007-04-06 21:49

本文Tags: , ,

搜索到原作者的话:
一般一个进程足够了,你可以把连接数设得很大。如果有SSL、gzip这些比较消耗CPU的工作,而且是多核CPU的话,可以设为和CPU的数量一样。或者要处理很多很多的小文件,而且文件总大小比内存大很多的时候,也可以把进程数增加,以充分利用IO带宽(主要似乎是IO操作有block)。

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

经我实践配置,多cpu+gzip+N多小文件+文件总大小大大超过内存 的环境(BBS啦~),设置为cpu的两倍较好。(不过一个nginx是4.3M噢)

标签: , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

2 Responses to “[译]nginx的worker_processes设为多少才合适?”

  1. Says:

    在我的实际使用中(nginx+php-cgi),还是觉得CPU*1为好

    一个CPU开启多个worker_processes的话,会导致负载瞬间狂升至20+

    相反一个CPU只开一个的话,会很稳!

  2. bianbian Says:

    嗯,这个要根据环境调节的。我的是8个CPU的服务器。。。另外,可以修改nginx的cc make参数,把gcc的-g(debug)参数去掉。可以大大减小编译后的bin大小。

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

(required)