Lighttpd: PHP_FCGI_CHILDREN correct value

lighttpdmemoryperformance

I'm running Lighttpd on 256MB RAM VPS (with low estimated traffic).

In order to optimize my server performances I decided to change these settings:

                    "PHP_FCGI_CHILDREN" => "1",
                    "PHP_FCGI_MAX_REQUESTS" => "20"

The reason why I set 1 child is that with setting there are 4 php_cgi processes:

2413 11336 /usr/bin/php-cgi
2415 4592 /usr/bin/php-cgi
2417 11336 /usr/bin/php-cgi
2419 27656 /usr/bin/php-cgi

If I set 4 I get >8 children. I'm wondering why and if this is ok.
Now my webserver is very fast, because I finally don't rely on swapping so massively as before.

thanks

Best Answer

As you can see in this FAQ there are three config options that control the number of mod_php processes.

  • PHP_FCGI_CHILDREN (defaults to 1)
  • max-procs (defaults to 4)
  • min-procs (ignored in current releases)

The formula to caluclate the initially spawned processes looks like this:

no_of_procs = max-procs * ( PHP_FCGI_CHILDREN + 1) 

This means, for every procs in max-procs launch PHP_FCGI_CHILDREN workers +1 Guardian process for each parent in max-procs.

Related Topic