Take the 2-minute tour ×

I'm setting up nginx to serve a Drupal install, and I seem to find conflicting information on the nginx worker processes setting. One site says you need two, one says you need five, one says one per processor...

How should I pick the number of nginx worker processes? If it makes a difference, it's a guest VM on a VMWare cluster, and I've given it one virtual processor.

share|improve this question

4 Answers 4

up vote 12 down vote accepted

Nginx unlike Apache and other process per connection webservers. It uses one master process to start and monitor a small number of worker processes that actually handle the connections. My recommendation is to start with the default number of workers, which is 1.

worker_processes  1;

You will only need to increase this if you find that the nginx worker is spending too much time blocked on IO. This will not by until it is serving many hundreds of requests per second.

You may also find these settings useful.

worker_rlimit_nofile 8192;

events {
    worker_connections  2048;
    use epoll;
share|improve this answer
Can you describe what "worker_rlimit_nofile 8192" is used for? –  The Pixel Developer Jun 10 '09 at 16:57
wiki.nginx.org/NginxHttpMainModule#worker_rlimit_nofile. This instructs the worker to increase its ulimit. –  Dave Cheney Jun 10 '09 at 17:53

On SMP systems, at least nCPU worker processes should be started: on quad-core - four etc. That's enougth for proxying.

If you are going to serve some sites with alot of static content, it would be better to add more workers - one per disk.

If your disk subsystem is to poor or load too high, nginx worker processes may become locked on I/O operations and could not serve other requests. In this case you should increase number of worker processes to some suitable value (may be tens), or add some memory for disk cache.

Look into "ps ax" printout: workers that are in "D" state are locked. Increase until get at least nCPU worker processes not blocked.

share|improve this answer

I'd start with one and add later if it appears to be a problem.

share|improve this answer

Run your server for a little bit, and check using top or ps what the memory size is of the worker process (you're looking for RSS memory).

Ideally you find a good average for your worker processes.

Then the formula becomes:

memory available for nginx / memory needed by worker = number of processes
share|improve this answer
Why would you want to spend it all? –  iny May 8 '09 at 18:23
Nginx is not apache and doesn't need to use all system memory. This is just wasting of resources. General rule of thumb is to use one nginx worker per CPU core. See Vadim's answer for additional hints. –  AlexD May 6 '11 at 6:55

Your Answer


