Safe log rotation
jmobile
nginx-forum at nginx.us
Wed Oct 1 21:30:04 UTC 2014
Hi,
I'd like to check how nginx handles command from
http://wiki.nginx.org/LogRotation
kill -USR1 `cat /var/run/nginx.pid`
I'm using it to recreate log files during rotation.
My question if any loglines can be lost in case time interval between
physical log files rotation and USR1 is large enough, like seconds? Or if
load is very high.
For example, while I was sending traffic to website with "ab -n 20 -c 10
http://test-s.mysite.com/static/99$i/logo/test.png > /dev/null 2>&1" in the
loop, I executed on the web-server this
tail -n 5 /mnt/vg0-lv0/access.log
rm -rf /mnt/vg0-lv0/access.log
sleep 15; sudo kill -USR1 `cat /var/run/nginx.pid`
sleep 2
head -n 5 /mnt/vg0-lv0/dj-access.log
2014-10-01T21:16:10+00:00,1412198170.957,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2486547,1,201,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:10+00:00,1412198170.957,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2486548,1,240,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:10+00:00,1412198170.958,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2486549,1,279,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:10+00:00,1412198170.959,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2486550,1,318,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:10+00:00,1412198170.964,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2486551,1,279,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
...
2014-10-01T21:16:27+00:00,1412198187.024,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2489854,1,162,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:27+00:00,1412198187.024,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2489855,1,162,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:27+00:00,1412198187.024,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2489856,1,162,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:27+00:00,1412198187.024,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2489857,1,240,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
2014-10-01T21:16:27+00:00,1412198187.024,10.120.71.11,"-","206.223.189.242",test-s.mysite.com,2489858,1,279,"-","-","-",-,"-","-","ApacheBench/2.3","-",HTTP/1.0,GET,http,/static/logo/test.png,"-",200,5676,5150,0.000,"-","-"
As you can see, there is a gap in timestamps sequence.
Is there a way to make sure all log-lines are going to be written on a
highly loaded web farm?
Thank you,
Roman Naumenko
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,253681,253681#msg-253681
More information about the nginx
mailing list