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.

If the web server is running slow, is there a way to see which files are responsible?

Edited:

Debian OS with Apache2 web server

share|improve this question

4 Answers 4

If you are trying to figure out which of your user's script is eating your resources, you could use the apache itk mpm, which runs vhosts under a user/group of your choice. Each request forks an apache process running as that user. Thus the ps/top output would show which user is running the script (and thus which vhost) - The downside is that itk is significantly slower of course. - Since with the normal prefork or worker mpm's apache handles multiple requests in one process for performance, it's harder to tell which requests are eating up your mojo.

If you're trying to find out exactly which functions in a php application are using up your resources, then you'll have to use xdebug. Obviously the xdebug profiling method would be a one time inspection for one php app, and not a solution for finding out which script belonging to which user in a shared hosting environment is consuming cpu time.

share|improve this answer

One thing I do, this is a bit inefficient, but I have a cron job run every minute which uses curl to save the output of http://localhost/server-status to a file with the date and time as the filename. That way I can pull those files up in a web browser and see what URLs were being accessed at that moment in time. COmparing a number of these shows which scripts use the most resources. But it's not very accurate, it's just a quick and dirty way to see what's going on.

For an accurate representation, use a profiler as others have suggested.

Let me know if you'd like to see the cron job.

share|improve this answer
    
The url's accessed at what time shows you the frequency of requests, not the time a php script takes to finish, doesn't it? If you want to a top-like output of requests you can use apachetop. –  jns Oct 23 '09 at 12:05
    
You're right, it doesn't show you the time a PHP script takes to finish, but it does have a column for how long each thread/child has been working on sending reply (The Req column) as well as what CPU percentage each thread is using. So it's a quick way to get some data, but not a total picture. Your answer sounds more thorough. –  Josh Oct 23 '09 at 12:11

Missing some useful information:

  1. OS?
  2. http daemon?

edit: have you checked out the normal process looking tools on a linux box like top, iostat, fuser, lsof?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.