zoukankan      html  css  js  c++  java
  • nginx日志request_time 和upstream_response_time区别

    1、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 。 指的就是从接受用户请求的第一个字节到发送完响应数据的时间,即包括接收请求数据时间、程序响应时间、输出 响应数据时间。

    2、upstream_response_time

    官网描述:keeps times of responses obtained from upstream servers; times are kept in seconds with a milliseconds resolution. Several response times are separated by commas and colons like addresses in the $upstream_addr variable

    是指从Nginx向后端(php-cgi)建立连接开始到接受完数据然后关闭连接为止的时间。

    从上面的描述可以看出,$request_time肯定比$upstream_response_time值大,特别是使用POST方式传递参数时,因为Nginx会把request body缓存住,接受完毕后才会把数据一起发给后端。所以如果用户网络较差,或者传递数据较大时,$request_time会比$upstream_response_time大很多。

    根据引贴对官网描述的翻译:
    upstream_response_time:从 Nginx 建立连接 到 接收完数据并关闭连接
    request_time:从 接受用户请求的第一个字节 到 发送完响应数据

    2、场景
    2.1 流程说明
    如果把整个过程补充起来的话 应该是:
    [1用户请求][2建立 Nginx 连接][3发送响应][4接收响应][5关闭  Nginx 连接]
    那么 upstream_response_time 就是 2+3+4+5 
    但是 一般这里面可以认为 [5关闭 Nginx 连接] 的耗时接近 0
    所以 upstream_response_time 实际上就是 2+3+4 

    而 request_time 是 1+2+3+4
    二者之间相差的就是 [1用户请求]的时间。

    来个网上的图说明情况:

    参考网址:https://blog.csdn.net/zzhongcy/article/details/105819628

    千里之行,始于足下。改变现在,就是改变未来。改变未来,从现在开始。 个人网站:http://www.wangkongming.cn
  • 相关阅读:
    c# 发送邮件
    C# Android 开发中使用 Sqlite.NET ORM
    VS2015 使用 Visual Studio Emulator For Android 调试无法命中断点的解决办法?
    asp.net 下载文件
    ScriptManager 发送错误到客户端
    C# 比较两个路径是否指向同一对象
    IIS 集成模式 导致 AjaxPro 无法正常运行
    C#编码、解码与ASP.NET编码解码对应函数
    FTP 命令连接(带用户名和密码)方法
    医学-药物-大环内酯类-阿奇霉素(Azithromycin)
  • 原文地址:https://www.cnblogs.com/wangkongming/p/14648067.html
Copyright © 2011-2022 走看看