You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tomasz Chmielewski <ma...@wpkg.org> on 2010/11/19 13:00:17 UTC

[users@httpd] debugging websites running on Apache?

How do you debug websites running on Apache?

Say, you have a website which is dog slow on the powerful server.


My favourite way (after checking the obvious errors from the logs) was 
to simply run Apache through strace, which would print where httpd 
processes connect to (and possibly hang, while waiting for a 
connection), what SQL queries they do, what files they try to open, 
where they write to etc.


This is great as it lets you see pretty everything which happens on the 
system, but has one major drawback: if anyone but you is using the 
webserver, you'll get a lot of noise in strace output - so debugging 
with strace is really only useful if you're the only user, which doesn't 
make it a great debugging tool on a busy webserver.


What are other debugging methods which can be used on a busy webserver? 
Ideally, I'd like to see all connections, database queries, files opened 
for read/write by Apache processes, with timestamps, as I connect from a 
given IP address (so all other noise is excluded).


-- 
Tomasz Chmielewski
http://wpkg.org

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] debugging websites running on Apache?

Posted by Scott Gifford <sg...@suspectclass.com>.
On Fri, Nov 19, 2010 at 7:00 AM, Tomasz Chmielewski <ma...@wpkg.org> wrote:

> How do you debug websites running on Apache?
>

I have a few tricks I use.

First, I try to write my applications so they can be run from the
commandline.  That means when they misbehave, I can run them directly under
strace or a debugger to see what's going on.

Others have suggested using the Xdebug profiler, but for what you are
looking at, the debugger might be more helpful.  You an just step through
the code one line at a time.

You can try running a Web server on an alternate port that only you use, so
that there will be no noise from other clients.

Sometimes I will have my applications write their PID to the error_log then
sleep for 30 seconds or so.  I can get their PID then and start an strace on
just that process.  You can limit this so they only do it when a request has
a particular parameter, comes from a particular IP address, etc.

Hope some of these techniques are helpful to you,

----Scott.