平时你们常常用php的curl模块,有时候排查问题没法正肯定位超时发生的阶段,这里主要把curl模块中的curl_getinfo函数说一下,发起 curl 请求后的几个关键时间点阶段以下图:php
根据上面的这个图 各个阶段的时间点能够用curl_getinfo获取到。curl
若是使用GuzzleHttp请求,则看下面实例:函数
$client = new \GuzzleHttp\Client();post
$res = $client->post($this->url, [
'form_params' => $formParams,
'headers' => $headers,
'timeout' => $this->timeout,
'connect_timeout' => $this->connectionTimeout,
'http_errors' => true,
'debug' => $this->debug,
// TransferStats 注意这个
'on_stats' => $this->debug ? function (TransferStats $stats) {
print_r($stats->getHandlerStats());
} : null,
]);this
具体每一个时间段的参数表明的具体含义,你们自行参考文档。url