Curl 追踪 请求延时问题

Posted by Sunday on 2019-06-11

背景原因:php curl 超时

1
2
3
(see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /data/web/oauth.sundayle.com/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:185
[2019-05-25 13:58:09] local.ERROR: GuzzleHttp\Exception\ConnectException: cURL error 28: Operation timed out after 150000 milliseconds with 0 out of 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /data/web/oauth.sundayle.com/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:185
[2019-05-25 14:10:12] local.ERROR: GuzzleHttp\Exception\ConnectException: cURL error 28: Operation timed out after 150001 milliseconds with 0 out of 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /data/web/oauth.sundayle.com/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:185

1
2
3
4
5
6
curl -o /dev/null -s -w %{time_namelookup}---%{time_connect}---%{time_starttransfer}---%{time_total}---%{speed_download}"\n" www.sundayle.com

0.060---0.067---0.074---0.074---2071.000
0.060---0.067---0.073---0.073---2105.000
0.060---0.068---0.076---0.076---2024.000
5.514---5.521---5.568---5.568---27.000
  • -o:把curl 返回的html、js 写到垃圾回收站[ /dev/null]
  • -s:去掉所有状态
  • -w:按照后面的格式写出rt
  • time_namelookup:DNS 解析域名www.sundayle.com的时间
  • time_commect:client和server端建立TCP 连接的时间
  • time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间
  • time_total:client发出请求;到web的server发送会所有的相应数据的时间
  • speed_download:下周速度 单位 byte/s

结果:IDC网络异常,域名反解异常。
使用ping更明显

1
2
3
4
5
6
7
8
9
10
11
time ping -c 1 sundayle.com
PING sundayle.com (14.29.182.126) 56(84) bytes of data.
64 bytes from 14.29.182.126: icmp_seq=1 ttl=44 time=9.57 ms

--- sundayle.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 9.573/9.573/9.573/0.000 ms

real 0m10.235s
user 0m0.000s
sys 0m0.002s

https://www.cnblogs.com/shiyiwen/p/7216189.html