平時你們常常用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