# Logs in wrong order

**URL:** <https://www.ruby-forum.com/t/logs-in-wrong-order/206752>\
**Category:** NGINX\
**Created:** [May 9, 2011, 12:52pm UTC](https://www.ruby-forum.com/t/logs-in-wrong-order/206752 "2011-05-09T12:52:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 9, 2011, 12:52pm UTC](https://www.ruby-forum.com/t/logs-in-wrong-order/206752/1 "2011-05-09T12:52:53Z")

</div>

When I hit the nginx server with a very rapid succession of requests  
from multiple clients, the logs will be out of order. For example, the  
log times would appear like this:

… 18:10:11 …  
… 18:10:11 …  
… 18:10:11 …  
… 18:10:12 …  
… 18:10:11 …  
… 18:10:12 …  
… 18:10:11 …  
… 18:10:12 …  
… 18:10:12 …  
… 18:10:12 …

Why would this be?

Posted at Nginx Forum:

> **[Logs in wrong order](https://forum.nginx.org/read.php?2,196690,196690#msg-196690)**
>
> When I hit the nginx server with a very rapid succession of requests from multiple clients, the logs will be out of order. For example, the log times would appear like this: ... 18:10:11 ... ... 18:10:11 ... ... 18:10:11 ... ... 18:10:12 ... ......

---

<div class="post-metadata">

**Author:** ![davidkazuhiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4bbf92/32.png) [@davidkazuhiro](https://www.ruby-forum.com/u/davidkazuhiro)\
**Post date:** [May 9, 2011, 1:08pm UTC](https://www.ruby-forum.com/t/logs-in-wrong-order/206752/2 "2011-05-09T13:08:59Z")

</div>

Hello!

On Mon, May 09, 2011 at 06:52:28AM -0400, davidkazuhiro wrote:

> … 18:10:11 …  
> … 18:10:12 …  
> … 18:10:12 …  
> … 18:10:12 …
> 
> Why would this be?

Time in different nginx worker processes may be slightly different  
as nginx only updates time once per event loop iteration (or even  
less frequently if timer\_resolution set). This in turn results in  
out-of-order times in logs you see when requests from different  
workers are logged.

Similar effect may be also seen when using log buffering (though  
in this case you’ll see blocks with successive times up to log  
buffer size, not individual lines).

Maxim D.

---

<div class="post-metadata">

**Author:** ![davidkazuhiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4bbf92/32.png) [@davidkazuhiro](https://www.ruby-forum.com/u/davidkazuhiro)\
**Post date:** [May 9, 2011, 2:13pm UTC](https://www.ruby-forum.com/t/logs-in-wrong-order/206752/3 "2011-05-09T14:13:55Z")

</div>

Oh I see, tricky. How is an event loop defined? Is there a value  
definable in nginx.conf which can shorten the event loop? Or can I just  
increase timer resolution to a really high number to make the log times  
more accurate?

Posted at Nginx Forum:

> **[Re: Logs in wrong order](https://forum.nginx.org/read.php?2,196690,196707#msg-196707)**
>
> When I hit the nginx server with a very rapid succession of requests from multiple clients, the logs will be out of order. For example, the log times would appear like this: ... 18:10:11 ... ... 18:10:11 ... ... 18:10:11 ... ... 18:10:12 ... ......
