Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
</IfModule>

mod_fcgid 2.2.10
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule !mod_fastcgi.c>
AddHandler fcgid-script fcg fcgi fpl php
</IfModule>
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.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=32
apc.ttl=7200

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

share|improve this question
    
I had something similar happen because of Apache module mod_security. Could you check if is installed ? –  atom Sep 27 '11 at 0:31
    
You could try Nginx. –  pvorb Oct 29 '11 at 11:06
    
I'm gonna throw this out there and say that it's one of two things. 1) Your application code is shit. 2) You should turn off Keepalive. –  Tom O'Connor Oct 29 '11 at 12:39
add comment

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(); ?

share|improve this answer
    
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 –  Scott Lundgren Jan 19 '11 at 22:25
add comment

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.

share|improve this answer
    
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. –  Scott Lundgren Jan 13 '11 at 21:33
add comment

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/

share|improve this answer
    
PHP 5.2.13, packaged from the IUS Community Project: iuscommunity.org/faq. Kernel is a 32 bit build of 2.6.18 –  Scott Lundgren Jan 13 '11 at 21:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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