• Nginx


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

  • 相关阅读:
    实验二 Nmap的实践
    《网络攻击与防范》第八周学习总结
    《网络攻击与防范》第七周学习总结
    《网络攻击与防范》第六周学习总结
    《网络攻击与防范》第五周学习总结
    《网络攻击与防范》第四周学习总结
    《网络攻击与防范》第三周学习总结
    《网络攻击与防范》第二周学习总结
    Linux 基础入门学习总结
    20169312 2016-2017-2《网络攻防实践》课程总结
  • 原文地址:https://www.cnblogs.com/thatsit/p/7078210.html
Copyright © 2020-2023  润新知