how to trouble shooting http request latency

Curl

1 Create one file such as curl-format.txt

[root@001 jiafu]# cat curl-format.txt 
 time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
   time_pretransfer:  %{time_pretransfer}\n
      time_redirect:  %{time_redirect}\n
 time_starttransfer:  %{time_starttransfer}\n
                    ----------\n
         time_total:  %{time_total}\n

2 Send Curl command with file with format

[root@001 jiafu]#  curl -w "@curl-format.txt" -o /dev/null -s https://www.baidu.com  
 time_namelookup:  0.001
       time_connect:  0.044
    time_appconnect:  0.295
   time_pretransfer:  0.296
      time_redirect:  0.000
time_starttransfer:  0.345
                    ----------
         time_total:  0.345

3 Analyst the result

time_appconnect The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed. (Added in 7.19.0)

time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.

time_namelookup The time, in seconds, it took from the start until the name resolving was completed.

time_pretransfer The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.

time_redirect The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. time_redirect shows the complete execution time for multiple redirections. (Added in 7.12.3)

time_starttransfer The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes time_pretransfer and also the time the server needed to calculate the result.

time_total The total time, in seconds, that the full operation lasted.

tcpDump

如下图:

附上https过程:

traceroute

[sbalabrahman@host ~]$ traceroute www.baidu.com
traceroute to www.baidu.com (145.20.193.63), 30 hops max, 60 byte packets
1  sjc02-wxp00-csw02-vl4085.xxx.com (10.255.29.5)  2.085 ms  2.156 ms  2.289 ms
2  sjc02-wxp00-srt01-vl4000.yyy.com (10.255.3.242)  0.930 ms  1.084 ms  0.878 ms

发布者

傅, 健

程序员,Java、C++、开源爱好者. About me

发表评论

电子邮件地址不会被公开。 必填项已用*标注