Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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   mars    GET /server-status HTTP/1.1
1-0 12392   0/0/0   W   0.00    0   0   0.0 0.00    0.00   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..


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   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   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   mars    GET /server-status HTTP/1.1
5-0 12506   0/101/101   _   29.95   8   314 0.0 0.07    0.07   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"

share|improve this question
Does this happen with static elements as well - or are we talking about pages that serve dynamic content? PHP for example? – Kvisle Oct 31 '11 at 20:13
I stopped/restarted apache, and without even visiting a php page on my server, apache began revving up all on its own. I don't think it's a php script.. – Tapefreak Oct 31 '11 at 20:21
up vote 0 down vote accepted

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.

share|improve this answer
I don't think it's PHP as I mentioned the server starts cranking before I access any php pages. Additionally - Recently I ran the same PHP scripts on MAMP, but then switched over to the OSX native PHP install and stopped using MAMP. – Tapefreak Oct 31 '11 at 20:26
You can use dtrace or dtruss from DTraceToolkit or ktrace to see what that worker is doing. You will need to run it as the apache user or as root. – Mircea Vutcovici Oct 31 '11 at 20:33
I did have a 16,000+ line /private/etc/hosts file, could that have something to do with apache revving up? (sorry bit of a noob) – Tapefreak Oct 31 '11 at 21:20
For some stuff apache has to do DNS lookup. It is using the resolver, which, usually will check the hosts file, then the DNS. That hosts file is big an the information that is keep there should be in the DNS. However, I do not think that on a dev workstation, this big hosts file will cause that huge CPU usage. – Mircea Vutcovici Oct 31 '11 at 21:57
Thank you for all the replies. Turns out, apparently it is a PHP issue, I have a javascript calling an API every 2 seconds for a dashboard refresh. When I commented out that server call, httpd went down to zero where it should be. I was incorrect on my 1st reply; the page was accessing the server after all. I'll take a look at syslog and see what's up with my PHP :) – Tapefreak Oct 31 '11 at 22:36

Your Answer


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.