简体   繁体   中英

Nginx $request_time and $upstream_response_time in Windows

I'm encountering some weirdness in my access log running Nginx on Windows. I've included $request_time in my access log as well as $upstream_response_time (running Django as fcgi upstream). It's my understanding that the log should represent request time in milleseconds, but it's output looks like this:

ip|date|request_time|upstream_response_time
xx.xx.xx.xxx|[29/Jan/2013:15:29:57 -0600]|605590388736.19374237|0.141
xx.xx.xx.xxx|[29/Jan/2013:15:30:39 -0600]|670014898176.19374237|0.156

Any ideas what the heck that gigantic number is!?

Here's the full log format (I removed a few columns in teh above example)

log_format  main  '$remote_addr|$time_local]|$request|$request_time|$upstream_response_time|'
                  '$status|$body_bytes_sent|$http_referer|'
                  '$http_user_agent';

Using pipe delimiters.

So as you suggest here comes the answer:

When you make request to your server ( nginx + upstream ) as GET then $request_time result with normal and acceptable value. That happens because your upstream server doesn't take part in it and even if it does it makes it properly.

Problems start when you are doing POST request. According to nginx doc value of $request_time variable (available only at logging) will be compute when all data have been send and connection have been closed (by all upstreams and proxy also). And only then info is appended to log.

So how to check if everything is correct? First do a GET request to your server and watch log file. Notice how much time it really takes to finish the call and add log info into file - it should be real value. Next do a POST request to your server and watch log file again. Here, probably, you will see that log isn't coming at all or after very long period.

What it means? Check your nginx conf and your upstream conf because somewhere could be a place where connection isn't closed and just hang in the air. Those connection could be renew after time by your OS or upstream server but after all it could cause some problems other than just strange $request_time value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM