Apache2 + mod_fastcgi + suexec + php5.2 = unstable on high load

apache-2.2fastcgihangsphp5

I am hosting several (~30) different sites on one server with apache2+fastcgi+suexec+php5. Sites have different loads and different execution times of their scripts (some of them process request for 5-7 seconds, some <1sek).

Sometimes when single site receives very high load (all php instances of this site are created and used) – whole apache server hangs. Apache (worker mpm) creates new processes up to the upper limit. It looks like it is starting to queue ALL new request for EVERY site, not only the one that has high load and quickly achieves process limits…
restart of apache solves the problem…

config:
FastCgiConfig -singleThreshold 1 -multiThreshold 10 -listen-queue-depth 30 -maxProcesses 80 -maxClassProcesses 12 -idle-timeout 30 -pass-header HTTP_AUTHORIZATION -pass-header If-Modified-Since -pass-header If-None-Match

(earlier have default -listen-queue-depth = 100, but it didn't change anything…)

Any suggestions?

Another question – how is implemented this listen queue? is it one queue for whole apache, or unique queue for every defined php apllication (suexec site)?

I would like to achieve something like this: when one site receives high load and its queue is full – server bounces next request, but only for this one site.. Other sites should work properly…

Best Answer

Apache 2.4 offers a new fastcgi proxy module (mod_proxy_fcgi) that can proxy requests to php-fpm. Using mod_proxy as an intermediary means you have access to all the mod_proxy options, including queueing and depletion parameters separate from the main server.

I would advise you to set it up on a test server with the apache 2.4 event MPM and php-fpm; you can tune each php pool for different applications, too.