Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This is a question about the correct process for trouble shooting Apache performance problems.

Some context. I run an Ubuntu 8.04LTS Virtual Machine with 360MB RAM. This serves LAMP websites; mainly based on Wordpress.

It doesn't get a lot of traffic (15k visits/month, 200k hits/month). But occasionally Apache goes beserk, consumes 100% CPU, thrashes the disks and generally causes the machine to grind to a halt (== doesn't serve webpages, won't respond to SSH commands etc)

So, my question is, how do I prepare to collect the correct information that will allow me to debug this kind of problem?

I'm as interested in the process as in the tools.

For example; the mysql slow query log seems like a reasonable way to debug slow SQL queries. Is there something similar for Apache? Is there some kind of logging tool that will show me which requests are the slowest / use the most CPU/memory? Or is this the wrong approach?

Thanks!

share|improve this question

2 Answers 2

up vote 0 down vote accepted

http://onlamp.com/pub/a/apache/2004/04/22/blackbox_logs.html

share|improve this answer
    
This article suggests extra data that you could put into the Apache log to get more information about individual requests. With specific applicability to my question above was this titbit: "The %T and %D directives refer to the time it takes to handle the entire transaction, including the amount of time it takes for the client to transmit data. If you see wide variances in the amount of time it takes to serve the same file, it may be related to a web client network problem." Of course this still leaves you with the problem of how to monitor the log files and identify slow requests –  David Laing Aug 5 '09 at 13:18
    
I would just tail -f log files in an ssh screen session. Justin does bring up a good point. This is more of a symptom of the problem than the problem itself, and this is often caused by apache consuming too much memory. See wiki.vpslink.com/Low_memory_MySQL_/_Apache_configurations for more apache tuning tips. –  Boohbah Aug 6 '09 at 14:34

Boohbah's answer will get you what you're asking for, but I think you might be asking for the wrong thing.

Slow requests via Apache isn't the problem, it's the effect. It sounds as though you've allowed Apache to consume too much memory, which then your box starts swapping, thrashing the disks. Tuning Apache is an art, not a science, so there's no copy/paste config that works for everyone, but here's a good article to get you started: Tuning LAMP @ O'Reilly.

Once you're done with that, look at setting up Munin to monitor your memory and CPU load.

share|improve this answer

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.