zoukankan      html  css  js  c++  java
  • 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字段。

  • 相关阅读:
    mybatis 源码分析(四)一二级缓存分析
    mybatis 源码分析(三)Executor 详解
    mybatis 源码分析(二)mapper 初始化
    mybatis 源码分析(一)框架结构概览
    Disruptor 详解 二
    Disruptor 详解 一
    JDK源码分析(12)之 ConcurrentHashMap 详解
    并发系列(7)之 ScheduledThreadPoolExecutor 详解
    数据结构系列(6)之 完全二叉堆
    并发系列(6)之 ThreadPoolExecutor 详解
  • 原文地址:https://www.cnblogs.com/thatsit/p/7078210.html
Copyright © 2011-2022 走看看