Httpd cranks up to 100% CPU on OSX Snow Leopard local dev machine, how to fix

apache-2.2httpdosx-snow-leopard

I have apache 2.2.17 running on Snow Leopard as my PHP dev stack. When I access a single page the CPU usage of httpd sort of goes wild – up and down between 30% and 100%, and stays that way, even if I don't keep accessing files on the server. I looked in the Apache log and there is only mention of a missing ico. file, so I can't see any problems there. It's a simple install of Apache/MySQL/PHP.

Anyone have an idea what could be causing this and/or how to LIMIT the amount of CPU for a process like httpd?

EDIT: here's what my server-status prints …

Server Version: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8r DAV/2 PHP/5.3.4
Server Built: Dec 1 2010 09:58:15
Current Time: Monday, 31-Oct-2011 21:00:49 CET
Restart Time: Monday, 31-Oct-2011 20:58:26 CET
Parent Server Generation: 0
Server uptime: 2 minutes 22 seconds
Total accesses: 101 - Total Traffic: 0 kB
CPU Usage: u28.39 s5.71 cu0 cs0 - 24% CPU load
.711 requests/sec - 0 B/second - 0 B/request
3 requests currently being processed, 0 idle workers
WWR.............................................................
................................................................
................................................................
................................................................
Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

Srv PID Acc M   CPU SS  Req Conn    Child   Slot    Client  VHost   Request
0-0 12388   0/101/101   W   34.10   0   0   0.0 0.00    0.00    127.0.0.1   mars    GET /server-status HTTP/1.1
1-0 12392   0/0/0   W   0.00    0   0   0.0 0.00    0.00    127.0.0.1   mars    GET /a/wp/ko/api/users/0 HTTP/1.1
2-0 12402   0/0/0   R   0.00    0   0   0.0 0.00    0.00    ?   ?   ..reading..

EDIT 2:

Another view of serverstatus shows:

Srv PID Acc M   CPU SS  Req Conn    Child   Slot    Client  VHost   Request
0-0 12499   0/2/2   _   0.00    22  0   0.0 0.00    0.00    127.0.0.1   localhost   GET /quant.js HTTP/1.1
1-0 12502   0/13/13 R   0.00    0   5   0.0 0.05    0.05    ?   ?   ..reading..
2-0 12503   0/0/0   R   0.00    0   0   0.0 0.00    0.00    ?   ?   ..reading..
3-0 12504   0/1/1   _   0.00    22  12  0.0 0.00    0.00    127.0.0.1   localhost   GET /z/8278/adzerk1_2_4_49,adzerk2_2_17_50?keywords=apache2,htt
4-0 12505   8/8/8   W   3.35    0   0   0.0 0.00    0.00    127.0.0.1   mars    GET /server-status HTTP/1.1
5-0 12506   0/101/101   _   29.95   8   314 0.0 0.07    0.07    127.0.0.1   mars    GET /a/wp/ko/api/users/0 HTTP/1.1
6-0 12507   0/3/3   R   0.65    0   0   0.0 0.00    0.00    ?   ?   ..reading..
7-0 12508   0/0/0   R   0.00    0   0   0.0 0.00    0.00    ?   ?   ..reading..

note the Adzerk – I have NOidea where this is coming from. this is just my local dev machine, how would apache be processing get requests for adzerk?? I saw another one for "Bidvertise"

Best Answer

If your page is a php page, then try to debug that page. Use the syslog() function to add debugging information and read the logs written by syslog to find out where it stops or where it is taking a lot of time to execute.

Better, you can use a PHP profiler or a PHP debugger.

Related Topic