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?
Regarding Nginx. It is more or less common to set
worker_processes
based on the formulawhere
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 theratio
.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 http://httpd.apache.org/docs/2.0/mod/worker.html 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 http://wiki.nginx.org/CoreModule#worker_cpu_affinity
hope it helps