官網描述:request processing time in seconds with a milliseconds resolution; time elapsed between the first bytes were read from the client and the log write after the last bytes were sent to the client。html
指的就是從接受用戶請求的第一個字節到發送完響應數據的時間,即$request_time包括接收客戶端請求數據的時間、後端程序響應的時間、發送響應數據給客戶端的時間(不包含寫日誌的時間)。nginx
官方文檔:http://nginx.org/en/docs/http/ngx_http_log_module.html後端
官網描述:keeps time spent on receiving the response from the upstream server; the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.。網絡
是指從Nginx向後端創建鏈接開始到接受完數據而後關閉鏈接爲止的時間。加密
從上面的描述能夠看出,$request_time確定比$upstream_response_time值大;尤爲是在客戶端採用POST方式提交較大的數據,響應體比較大的時候。在客戶端網絡條件差的時候,$request_time還會被放大。日誌
官方文檔:http://nginx.org/en/docs/http/ngx_http_upstream_module.htmlorm
除了上述的request_time和upstream_response_time比較經常使用,在新的Nginx版本中對整個請求各個處理階段的耗時作了近一步的細分:server
$upstream_connect_time(1.9.1):htm
keeps time spent on establishing a connection with the upstream server (1.9.1); the time is kept in seconds with millisecond resolution. In case of SSL, includes time spent on handshake. Times of several connections are separated by commas and colons like addresses in the $upstream_addr variable.接口
跟後端server創建鏈接的時間,若是是到後端使用了加密的協議,該時間將包括握手的時間。
$upstream_header_time(1.7.10):
keeps time spent on receiving the response header from the upstream server (1.7.10); the time is kept in seconds with millisecond resolution. Times of several responses are separated by commas and colons like addresses in the $upstream_addr variable.
接收後端server響應頭的時間。
因此在經過nginx的access_log來分析後端程序接口響應的時候,須要在nginx的log_format中添加$upstream_response_time字段。