Forum: NGINX timer_resolution / $request_time

Posted by Martin Xavier (xavierm)
on 2010-08-26 23:24
(Received via mailing list)
Hello,

I've been using this settings for a while:
timer_resolution 100ms;
log_format combined_time '$remote_addr - $remote_user [$time_local]  '
                   '"$request" $status $body_bytes_sent '
                   '"$http_referer" "$http_user_agent"'
                   ' $request_time';
access_log /var/log/access.log combined_time;

Right now i'm needing more precise timestamp in logs
=> finding requests that took less than 50ms to complete.

I would like to know what are the drawbacks of using a lower number
(i.e 10ms, 0ms or not setting at all timer_resolution) and overhead that 
would cause (if any).

thanks

-xavier
Posted by Maxim Dounin (Guest)
on 2010-08-27 01:00
(Received via mailing list)
Hello!

On Thu, Aug 26, 2010 at 11:23:47PM +0200, Xavier Martin wrote:

> Right now i'm needing more precise timestamp in logs
> => finding requests that took less than 50ms to complete.
> 
> I would like to know what are the drawbacks of using a lower number
> (i.e 10ms, 0ms or not setting at all timer_resolution) and overhead that would cause (if any).

With timer_resolution unset (set to 0, default) nginx will call
gettimeofday() on every event loop iteration.  With
timer_resolution set nginx will schedule
gettimeofday() calls at specified interval.

Obviously changing it from 100ms to 10ms would cause 10 times
more gettimeofday() calls.  But most likely you won't notice.

But actually I would recommend using the default (i.e. unset).
It's not really different from 10ms on loaded servers and wouldn't
cause extra work on otherwise idle servers.

Maxim Dounin
Posted by Arthur Blake (Guest)
on 2010-08-27 20:42
(Received via mailing list)
Is there anyway to get the request time in microseconds resolution in 
order
to emulate Apache's %D log format option?
It looks like the only option at this time is to just fake it with 
something
like "$request_time000" (since 1 millsecond = 1000 microsecond)
Posted by Arthur Blake (Guest)
on 2010-08-27 21:17
(Received via mailing list)
that doesn't actually work:

[emerg]: unknown "request_time000" variable

any ideas?
Posted by Maxim Dounin (Guest)
on 2010-08-28 23:34
(Received via mailing list)
Hello!

On Fri, Aug 27, 2010 at 02:41:52PM -0400, Arthur Blake wrote:

> Is there anyway to get the request time in microseconds resolution in order
> to emulate Apache's %D log format option?

No.

> It looks like the only option at this time is to just fake it with something
> like "$request_time000" (since 1 millsecond = 1000 microsecond)

${request_time}000

Maxim Dounin
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.