Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?
jerome at loyet.net
Tue Jun 15 23:32:16 MSD 2010
2010/6/15 Reinis Rozitis <r at roze.lv>:
>> 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 *
this is right only if your webserver is ONLY serving dynamic content
without caching. If nginx is serving static file or dynamic content
from cache, you will have less connections to the fcgi backend than
you have incoming connections on the web server. There is no way to
know exactly how many fcgi concurent connexions. You can set
max_children depending on your RAM. If you have 2Go of RAM, you'll
want to keep a part of this memory for system caching (let say 500
Mo). You'll keep some for the system and the others apps (nginx) (let
say 256Mo). It'll stay a bit more than 1Go of RAM dedicated to fcgi.
Depending on what your scripts are doing, you can imagine a memory
size for one fcgi process and you can then deduce the max_children.
If you think your PHP process won't consume more than 20Mo, you can
set max_children to 1256 (Mo) / 20 (Mo) =~ 62.
But it's all depending on what your application is doing, how the
audition is surfing the website, you system, ...
> 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
> 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
> nginx mailing list
> nginx at nginx.org
More information about the nginx