Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to optimize my apache and nginx installations and have been looking for information on how to setup correct number or min/max servers and connections in Apache and worker processes in Nginx.

I was wondering whether or not Apache and Nginx take advantage of multy core processors and how to set configuration in Apache and Nginx?

For example, lets say I have a 4 core processor, should I set workers to 4 in nginx? what should I set spare server in apache to?

share|improve this question

Regarding Nginx. It is more or less common to set worker_processes based on the formula

worker_processes = num_cores * ratio

where ratio is between 1.0 and 2.0, depending on the load, hardware, etc. Use your OS utilities to determine if all the cores are loaded to tune the ratio.

share|improve this answer

yes you can set 4 workers in nginx, mind you though keep the connections to 1024 max unless you know what you are doing. (you can hit OS max file open limit)

Regarding Apache its no secret A lot of it is trial and error as it seems to be affected by what application Apache is handling. So you should start with something standard and adjust overtime to see what works best for you. The idea is to prevent apache from having to launch new servers frequently and on the other to avoid having too many idle processes.

further if you're using nginx on the same server as apache it will help to keep the workers to just 2 each for apache and nginx. for nginx sometimes settings workers does not work so you can define cpu affinity see

hope it helps

share|improve this answer
So if I have 4 cores, but only have 1 worker in nginx then I'm not fully using my servers capabilities? – user80666 Jun 20 '11 at 2:41
not really, if you do a "top" and then press "1" during operation you can see that nginx does not really need a lot of CPU. It can run well even on single CPU. However there are other processes like php/mysql or system processes that could use the free cpu. nginx uses by far the least amount of CPU even under heavy load (for static files). Always leave extra room to grow on a dedicated box. – Vangel Jun 20 '11 at 7:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.