# Timer\_resolution / $request\_time

**URL:** <https://www.ruby-forum.com/t/timer-resolution-request-time/193945>\
**Category:** NGINX\
**Created:** [August 26, 2010, 11:24pm UTC](https://www.ruby-forum.com/t/timer-resolution-request-time/193945 "2010-08-26T23:24:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@martinx](https://www.ruby-forum.com/u/martinx)\
**Post date:** [August 26, 2010, 11:24pm UTC](https://www.ruby-forum.com/t/timer-resolution-request-time/193945/1 "2010-08-26T23:24:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@martinx](https://www.ruby-forum.com/u/martinx)\
**Post date:** [August 27, 2010, 1:00am UTC](https://www.ruby-forum.com/t/timer-resolution-request-time/193945/2 "2010-08-27T01:00:47Z")

</div>

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 D.

---

<div class="post-metadata">

**Author:** ![martinx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@martinx](https://www.ruby-forum.com/u/martinx)\
**Post date:** [August 27, 2010, 8:42pm UTC](https://www.ruby-forum.com/t/timer-resolution-request-time/193945/3 "2010-08-27T20:42:46Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![martinx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@martinx](https://www.ruby-forum.com/u/martinx)\
**Post date:** [August 28, 2010, 11:34pm UTC](https://www.ruby-forum.com/t/timer-resolution-request-time/193945/4 "2010-08-28T23:34:44Z")

</div>

Hello!

On Fri, Aug 27, 2010 at 02:41:52PM -0400, Arthur B. 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 D.

---

<div class="post-metadata">

**Author:** ![martinx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6a8cbe/32.png) [@martinx](https://www.ruby-forum.com/u/martinx)\
**Post date:** [August 27, 2010, 9:17pm UTC](https://www.ruby-forum.com/t/timer-resolution-request-time/193945/5 "2010-08-27T21:17:53Z")

</div>

that doesn’t actually work:

[emerg]: unknown “request\_time000” variable

any ideas?
