Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis r at roze.lv
Tue Jun 15 23:21:36 MSD 2010


> I will definitely try it but I still looking for equation to set numbers
> like worker_processes, worker_connections & PHP_FCGI_CHILDREN (or PHP_FPM
> counterpart) perfectly.

The basic approach usually as far as I know is to set worker_processes based 
on your CPU core count (either identical or sometimes there is benefit 
setting with some multiplier - 2*cores (I have seen some improvements when 
using nginx as on-the-fly image resizer to utilise the box more)).

worker_connection - typical 1024 or 2048 usually is enough. Bassically the 
math is based on max_clients where: max_clients = worker_processes * 
worker_connections

Anyways nginx should complain in error log if the settings are too low and 
all the workers are exausted (like you have thousands of keepalive/active 
connections).


The same with FPM - the basic settings which come with the sample config 
should be enough. If you leave the default notice error level log FPM should 
tell you if all of the php pool is fully used and there is a need to 
increase the setting.

So in short - both of the software products are clever enough to tell you 
what could be the optimal setting for you based on the workload of the box.


p.s. remember also to tweak other system settings - like maximum open file 
descriptors, tcp port range etc

rr 



More information about the nginx mailing list