日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx - request_time和upstream_response_time的区别

發布時間:2025/3/21 Nginx 76 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx - request_time和upstream_response_time的区别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

request_time

官網描述: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。

指的就是從接受用戶請求的第一個字節到發送完響應數據的時間,即$request_time包括接收客戶端請求數據的時間、后端程序響應的時間、發送響應數據給客戶端的時間(不包含寫日志的時間)。

官方文檔:http://nginx.org/en/docs/http/ngx_http_log_module.html

upstream_response_time

官網描述: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.html

“other” times

除了上述的request_time和upstream_response_time比較常用,在新的Nginx版本中對整個請求各個處理階段的耗時做了近一步的細分:

$upstream_connect_time(1.9.1):

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字段。

?

總結

以上是生活随笔為你收集整理的Nginx - request_time和upstream_response_time的区别的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。