Guest123
Guest123

Reputation: 105

Meaning of PHP_FCGI_CHILDREN and max-procs in Lighttpd and Fastcgi configuration

There are 4 fields in fastcgi configuration, max-procs, max-load-per-proc, PHP_FCGI_CHILDREN,PHP_FCGI_MAX_REQUESTS :

fastcgi.server = ( ".php" =>
  (( "socket" => "/tmp/php-fastcgi.socket",
     "bin-path" => "/usr/local/bin/php",
     "max-procs" => "2",
     "bin-environment" => ( 
                           "PHP_FCGI_CHILDREN" => "3",
                           "PHP_FCGI_MAX_REQUESTS" => "10000" )
   ))
)

So, there would be 1 fastcgi backend with 2 processes. These processes accept load.

I don't understand the following:

  1. What is the significance of PHP_FCGI_CHILDREN?
  2. Is a request handled by a PHP_FCGI_CHILDREN or by a proc?
  3. Which parameter decides the max-load of 1 proc? And what is its default value?
  4. Does the max-load of a proc have any relation with PHP_FCGI_MAX_REQUESTS?
  5. What would happen if PHP_FCGI_CHILDREN=0? It was mentioned that max-proc = number of watchers and max-proc*PHP_FCGI_CHILDREN= number of workers. What does that mean?
  6. When is a proc said to be overloaded?

Upvotes: 4

Views: 6811

Answers (1)

user9880886
user9880886

Reputation:

Hope this sheds some light on the situation

A little context for the rest of this answer:

A 'main' process is a process that gets spawned. This is able to share all it's resources [like memory] with its children. But however does not handle php requests, think of this like a container for the actual request handlers

A 'child' process is what actually handles the php requests. This in turn also is a very big factor in how much load you put on a 'main' process.

The general strategy here should be to minimize the amount of 'main' processes and maximize the amount of 'child' processes while maintaining stability since child processes will have a shared opcache, memoryspace and system resources with thier siblings.

  1. PHP_FCGI_CHILDREN = The amount of child processes a 'main' process can spawn.
  2. Requests are handled by PHP_FCGI_CHILDREN
  3. PHP_FCGI_CHILDREN and it defaults to 1, and if set to another value always adds 1 to the number you specify [so if you specify it as 1 it adds 1, so it will become 2]
  4. Yes it does
  5. If you set PHP_FCGI_CHILDREN=0 each 'main' process will only spawn 1 child process
  6. A proc is overloaded when it can't handle any more requests [due to lack of resources] This is very system/envirement dependent so sorry for being so vaque here

Upvotes: 3

Related Questions