Why is my apache2, mod_fcgid, php configuration causing 100% cpu usage?

Posted by Scott Lundgren on Server Fault See other posts from Server Fault or by Scott Lundgren
Published on 2011-01-11T03:58:04Z Indexed on 2011/01/11 4:55 UTC
Read the original article Hit count: 304

Filed under:
|
|
|
|

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

© Server Fault or respective owner

Related posts about linux

Related posts about apache