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.