关于 request_time 和 upstream_response_time - V2EX
happywowwow
V2EX    NGINX

关于 request_time 和 upstream_response_time

  •  
  •   happywowwow May 18, 2016 4326 views
    This topic created in 3652 days ago, the information mentioned may be changed or developed.

    贴一部分 nginx 的 access.log 的数据, 分别是

    method, request_time, upstream_response_time, request_time - upstream_response_time

    "GET 0.143 1.131 0.988 "GET 0.053 0.053 0 "POST 0.029 0.029 0 "GET 0.037 3.034 2.997 "GET 0.138 0.690 0.552 "POST 0.072 0.072 0 "GET 0.063 3.833 3.77 "GET 0.056 1.055 0.999 "POST 0.029 3.471 3.442 "GET 0.347 0.378 0.031 "GET 0.074 3.899 3.825 "GET 0.077 0.077 0 "GET 0.018 0.018 0 "GET 0.030 0.030 0 "GET 0.034 0.034 0 "GET 0.063 0.063 0 "POST 0.031 0.035 0.004 "POST 0.031 0.031 0 "POST 0.030 0.030 0 "GET 0.077 3.552 3.475 "GET 0.137 0.140 0.003 "POST 0.030 0.033 0.003 "GET 0.285 1.557 1.272 "GET 0.056 0.056 0 "GET 0.076 3.960 3.884 "GET 0.076 3.453 3.377 "POST 0.124 0.186 0.062 "HEAD - 0.000 0 "GET 0.007 1.006 0.999 "POST 0.031 0.925 0.894 "POST 0.032 0.032 0 "GET 0.048 0.675 0.627 "POST 0.030 0.030 0 

    想了解一下在 cpu, 内存都没满的情况下, 为什么 request_time 和 upstream_response_time 在部分请求中相差这么大.

    以我现在的了解, request_time 是外网请求进出 nginx 的时间

    而 upstream_response_time 是 nginx 将请求交给后端服务器处理到返回的时间

    Supplement 1    May 1, 2016
    顺序 应该是

    method, upstream_response_time, request_time, request_time - upstream_response_time
    10 replies    2016-05-18 23:49:50 +08:00
    eric6356
        1
    eric6356  
       May 18, 2016
    因为 client 和 server 之间的网络情况各不相同吧?
    ryd994
        2
    ryd994  
       May 18, 2016
    是不是两个时间反了? request_time>upstream_response_time 才对
    因为 nginx 有 buffer ,在返回数据量不大的情况下,数据全部进 buffer ,关闭上游连接,然后慢慢发给 client
    happywowwow
        3
    happywowwow  
    OP
       May 18, 2016
    @ryd994 没有反啊 第四列数据都是大于等于 0 的
    happywowwow
        4
    happywowwow  
    OP
       May 18, 2016
    @eric6356 诶? 什么意思
    eric6356
        5
    eric6356  
       May 18, 2016
    @happywowwow request_time 是 nginx 接到 request 的时间,然后 nginx 会等 client 把全部的数据发过来存 buffer ,再交给 upstream 。 client 和 server 之间的网络情况各不相同,这会导致这个时间差各不相同。
    happywowwow
        6
    happywowwow  
    OP
       May 18, 2016
    @eric6356 部分请求需要 秒 级别的返回 这算是正常么
    eric6356
        7
    eric6356  
       May 18, 2016
    @happywowwow 具体讲的可能有点不对,但大致是这个意思
    ryd994
        8
    ryd994  
       May 18, 2016
    @happywowwow 第一行 0.143 1.131 你说哪个大?
    eric6356
        9
    eric6356  
       May 18, 2016
    @happywowwow 我认为很正常,国内的网络,某些时候跨运营商跳来跳去能访问到已经很不容易了。
    happywowwow
        10
    happywowwow  
    OP
       May 18, 2016
    @ryd994 啊.. 才发现 写反了..

    method, upstream_response_time, request_time, request_time - upstream_response_time
    About     Help     Advertise     Blog     API     FAQ     Solana     3083 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 48ms UTC 12:24 PVG 20:24 LAX 05:24 JFK 08:24
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86