Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Apache 2.2.17 on Ubuntu - Apache seems to be occupying 100% of the CPU. How can I know what Apache is busy doing to cause such high CPU usage?

Should I use some stack tracing tools? Or perhaps there are some Apache plugins that can dump its internal state?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Check access log and error log files (locations are defined within your "httpd.conf" file) for a lot of activity (newest entries are at the end of the file -- use "tail -f access.log" to watch it live).

If there's no activity showing up in your log files, then it's probably some code that's gotten stuck in an endless loop. Restarting Apache HTTPd will fix that temporarily, but you'll definitely want to review custom code (are you using mod_perl2, CGI Perl, PHP, or something else?), particularly code that was modified/added after you believe this symptom started to appear.

The "server-status" module (which should be included in a default build) may provide some insight as well.

If restarting results in 100% activity again, then you may have some code that's being loaded with Apache HTTPd that's causing the problem, or one of the modules.

Are you doing anything complicated with the configuration? Are you using mod_perl2, CGI Perl, PHP, or something else? Which version of Apache HTTPd are you using? Which Operating System are you running it on (I assumed Unix or Linux since these Operating Systems are better-suited to be web servers and are what most people seem to choose)?

share|improve this answer
1  
There're a lot of activities in the log files, but the duration is not shown, so I can't measure which page caused the problem. And yes, I'm heavily using mod_perl, mod_rewrite, mod_python, etc. server-status is very helpful, but I couldn't get a 10 most time-consuming urls in the status page, but it's very useful. –  Xiè Jìléi Jun 14 '11 at 1:35
1  
I'm a big fan of mod_perl2, and I'm always happy to meet other ModPerl developers (we don't run into very many problems, so we tend to be a pretty quiet community -- you may be interested in perl.apache.org/maillist/modperl.html). The logs won't show how long a process took to complete, but they will help you narrow down some potential culprits. Can you determine what time the 100% CPU utilization spikes up? If so, then you can easily look at the time when that starts (if it happens immediately, it could be a module, including a mod_perl2 custom module, at load time). –  Randolf Richardson Jun 14 '11 at 3:18

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.