Page load makes a quick initial connection, then hangs about 10 seconds before the page renders. When the server load goes up I start watching top & I see that both CPUs get pegged at times to 100% by between 4-8 processes of php-cgi. My theory is that since I never see RAM usage never go above 50%, that apache is able to handle the requests coming in, but is queueing them for PHP to process. What is wrong with my mod_fcgid/php configuration ?

RHEL 5.4
2 Xeon E5420s @ 2.50 Ghz
4 Gb RAM

Apache 2.2.3
Timeout 30
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 5
<IfModule worker.c>
StartServers 2
MaxClients 300
MinSpareThreads 25 MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0

mod_fcgid 2.2.10
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule !mod_fastcgi.c>
AddHandler fcgid-script fcg fcgi fpl php
SocketPath run/mod_fcgid
SharememPath run/mod_fcgid/fcgid_shm
DefaultInitEnv PHPRC "/etc/"
FCGIWrapper /usr/bin/php-cgi .php
MaxRequestsPerProcess 1500
MaxProcessCount 20
IPCCommTimeout 240
IdleTimeout 240

APC 3.0.19
extension = apc.so

APC cache is 43% used with a 99% hit rate

  • I had something similar happen because of Apache module mod_security. Could you check if is installed ?
    – atom
    Sep 27, 2011 at 0:31
  • You could try Nginx.
    – pvorb
    Oct 29, 2011 at 11:06

3 Answers 3


Couple of things I would check off the bat ...

First, do you have anything printing out to your Apache Error logs ? You may need to up the log level to "warn" so as to see output from your CGI processes. Though in this case bringing it up to debug may be more beneficial as apache will print out fcgi related logging info. Checking out the access logs might be helpful also to see whether apache's returning 403, or 500 codes.

Second, what PHP code are you attempting to execute and how are you testing it ? Though I would have expected to see more cgi processes, there might be something up on this end. Are you going with a heavy script or something simple like a phpinfo(); ?

  • I have a couple entries in error_log but haven't been able to make sense of them: [warn] (103)Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function [notice] mod_fcgid: /var/www/html/index.php total process count 20 >= 20, skip the spawn request [notice] mod_fcgid: process /var/www/html/index.php(8988) exit(server exited), terminated by calling exit(), return code: 0 The PHP code is an installation of Drupal 6.20 tested with: ab -k -n 1000 -c 5 testserver.network.net Jan 19, 2011 at 22:25

Do you have any other accelerator (zend optimizer, eAccelerator, etc) configured in addition to APC? I had something similar happen when APC cache and zend optimizer were both enabled. Apparently they conflict with each other.

  • Nope, APC is the only optimizer that's been loaded in. The site supports 40K visitors a day with a load level < .50 but once it starts getting more traffic than that is when I see the issues occur. Jan 13, 2011 at 21:33

What version of PHP are you running? Is your kernel 32 or 64 bit?

If so - see: http://www.theregister.co.uk/2011/01/04/weird_php_dos_vuln/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.