Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?
r at roze.lv
Tue Jun 15 23:08:48 MSD 2010
> I read somewhere that 2 PHP processes do not share APC cache. So if I
> have 10 PHP_FCGI_CHILDREN - that means 10 times cache size.
That could be true if the php processes are spawned seperatly (by webserver)
each time a client request comes in - which is slow as hell (and somewhat
mimics the apache forking mechanism).
The preferred way (especially for high concurrency) is to spawn the php as
permanent process and the webserver (nginx) talks to it through fastcgi (
http://wiki.nginx.org/NginxHttpFcgiModule ) - (you just provide ip:port -
which gives you also the ability if needed to use multiple boxes) that way
all the php processes have the same APC opcode cache / shared memory (and
there is no need to recompile script each time a new child is spawned). Not
to mention other benefits like persistant connections (to memcache / db /
etc) which aren't killed each time a request finishes but reused on next.
spawn-fcgi was kinda early way to do this (came from lighttpd) but now the
inbuilt FPM sapi has much more control and options (like to kill processes
which run for too long / monitor/backtrace the code) to miss the opportunity
to try it out.
More information about the nginx