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'm running Apache and every once in a while [once every other day it seems] the number of apache processes will jump considerably and each one takes up around 75% cpu usage.

I would love to be able to track down these processes to the actual virtual host that is getting the requests. Any suggestions?

share|improve this question
Have you looked in the apache logs? You may notice a large number of requests at that time (probably a search engine indexing your site) or a request to a particular CGI that uses lots of CPU. Also try doing a 'top" during the event to see what child process is using CPU (if it's a CGI) – Chris Nava Mar 29 '11 at 20:46
thanks Chris; I have been down that route, I even have logwatch separating out the virtual hosts log reports into different reports so I can better track who is up to what, but what that does not do is tell me what page is doing what at the particular time of the spike..... as for CGIs, yes they are easy enough to track as they are all associated with a user name - unfortunately [??] none of them are misbehaving. there are just under 100 domains, so it's pretty difficult to nail one down fast enough, i.e. during the spike. – Sean Kimball Mar 29 '11 at 21:26
sorry - let me qualify that - it's difficult to track this in a log as some of these sites get lots of traffic, but light traffic - not necessarily heavy on the CPU resources... so it's not possible to differentiate cpu usage using the apache logs... :( – Sean Kimball Mar 29 '11 at 21:28
up vote 1 down vote accepted

Apache's logging has a lot of nifty options, and there are a couple of good options to try in order to figure out what is going on. I would start with %D or %T which logs the time it took Apache to complete the request, on the assumption that whatever is taking up all the CPU time is also taking more "real" time to do.

If you are using the Prefork MPM you can format your logs to include %P. This will log the process ID of the apache process actually handling the request so you can match the request to your top output. Process IDs will get reused pretty quickly (due to multiple requests per child) so you'll still need to check the timestamp on the log but you should be able to find the specific request that apache process was handling at that time.

If you're using Worker, then you can try %{tid}P and matching that to top -H which prints the thread ID in the PID column.

share|improve this answer

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.