海峰 刘
September 22, 2013 10:00PM
Hi experts,

I am reading the log module source code, there is something difficult to make sure, so I ask for your help.

Access log module use a buffer to buffer log entries before writing to the file system, the buffer is initialised before the worker processes are forked, so I guess after the fork(), each worker has a copy, this also explains why there is no lock-unlock operations while using the buffer. To be sure about that, I did a simple test:

1, configure nginx to use 16k access log buffer, use the default keep-alive time(65), work in master-workers mode with a few worker processes;
2, open one browser, access nginx server, refresh a few times, no access log generated;
3, open another browser, do the same thing as 2, until the access log was flushed;

I think there is a chance that the two browser was served by different worker processes, and log entries may be buffered in different buffers, which buffer get full first, which will be flush first. According that, the order of the log entries could be messed up. Unfortunately, I didn't see that after testing for a few times.

My question is, Am I wrong about the log module behaviour, or I didn't get the right way to test it?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Log module question: does the buffer mess up the order of the log entries?

海峰 刘 September 22, 2013 10:00PM

Re: Log module question: does the buffer mess up the order of the log entries?

Maxim Dounin September 23, 2013 07:38AM

Re: Log module question: does the buffer mess up the order of the log entries?

Valentin V. Bartenev September 23, 2013 01:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 298
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready