httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Idzerda, Edan" <Edan_Idze...@PremierInc.com>
Subject Logging "server wait" duration
Date Fri, 22 Jan 2010 20:13:17 GMT
I've loved using %D microsecond request duration logging for helping track down performance
issues.  But I've always thought, "wouldn't it be cool if you could log how long Apache spent
processing the request, versus how long it spent *sending* the request?"   So finally last
week I said, "Self, why don't you write it?"  :)

I added a %w formatting directive to CustomLog via mod_log_config's log_pfn_register, and
I used request_rec's notes table to store the serverwait microseconds until the request is
finished.  It's been a long time since I've done much C, so my solution for storing the microsecond
duration in the APR "table" was:

static const int get_server_wait(request_rec *r) {
    apr_time_t duration = apr_time_now() - r->request_time;
    apr_table_setn(r->notes, "serverwait-usec",
                apr_psprintf(r->pool, "%" APR_TIME_T_FMT, apr_time_usec(duration)));
    return OK;
}
I hooked this function into the Fix Ups phase, because it seemed the most popular "end of
apache processing phase."  I still need to test in a proxy to JBoss type situation, but I
know at least using a simple CGI script it didn't measure the CGI script processing, but I
thought that might be unavoidable... And we don't really have many CGI scripts in production
anyway.

I've done some brief load testing with "ab" and so far I don't think it adds a measurable
amount of lag.  I have two questions.  First,  might there be a better hook phase to use to
really capture Apache processing time?  And second, might there be a more efficient way to
temporarily store the "serverwait-usec" value than doing a string conversion?

I'd be happy to share the code if anyone's interested.  Cheers!

- edan








-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer.  Thank you.  Premier Inc.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message