Auto detect the number of CPU's and set worker_processes

Joshua Zhu zhuzhaoyuan at gmail.com
Sun Sep 16 03:48:19 UTC 2012


Hi,

On Sun, Sep 16, 2012 at 7:55 AM, justin <nginx-forum at nginx.us> wrote:

> I am trying to get fancy and have `nginx.conf` auto-detect the number of
> CPU's on the server and then set `worker_processes` to that number. Here is
> what I have:
>
>     worker_processes $(cat /proc/cpuinfo | grep "processor" | sort -u | wc
> -l);
>
> Unfortunately, that is throwing an error on nginx start. Is it even
> possible
> to run shell commands from inside nginx configuration files?
>

It's not supported in current nginx.

But you may try out tengine, which is a nginx distribution and has the
exact feature you want: http://tengine.taobao.org/document/core.html
More features can be found at: http://tengine.taobao.org/

Regards,

-- 
Joshua Zhu
Senior Software Engineer
Server Platforms Team at Taobao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120916/8827781f/attachment.html>


More information about the nginx mailing list