Welcome! Log In Create A New Profile

Advanced

Re: 回复:Re: using nginx workers

December 06, 2011 07:15PM
> to set as many workers as number of physical CPU
> cores you have
> (or virtual, if you in VM environment).

The reason why you should set the number of workers to the number of CPU cores is that every worker is single threaded and that's why every worker will use up just one core. So 1 worker on a quad core would give you a max of 25% cpu usage. On a quad core you would use 4 workers (worker_processes) so one worker is scheduled to 1 cpu core. More workers would increase swapping processes in and out of the cpu cache.

Additionally, if you run linux you might wanna check out
ulimit -n
as this will tell you whats the maximum number of file descriptors (= ~ max connections per worker) and set worker_processes to this value (max!).

To check out how many connections you are using you can add this to your virtual host config (probably at /etc/nginx/sites-available/default)

location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}

and run
curl localhost/nginx_status in console (assume you use linux).
to see how many connections you really need.
max connections = worker_processes * worker_connections

If running the latest precompiled stable (1.0.10) you can also check out munin http://munin-monitoring.org/ as it comes with an nginx plugin and shows you the number of connections in graphs by day, week, month and year. (munin is the best free monitoring tool i could find on the web. its definitely worth checking out to discover problems, watch the growth and to predict upcoming bottlenecks

Hope it helps.
Subject Author Posted

using nginx workers

fanboy December 06, 2011 03:56AM

Re: using nginx workers

Valentin V. Bartenev December 06, 2011 04:06AM

回复:Re: using nginx workers

laijingli2006 December 06, 2011 04:18AM

Re: 回复:Re: using nginx workers

Valentin V. Bartenev December 06, 2011 04:46AM

Re: 回复:Re: using nginx workers

bartbant December 06, 2011 07:15PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 127
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready