巧用curl命令定位性能瓶頸

直接上圖↓

圖1

 

上面的命令,可以查看http請求各個環節的耗時情況,能夠幫助我們排查和定位問題。

 

要實現上圖的輸出效果,需要將下面格式化文本提前準備好。

圖2

有的朋友可能好奇,圖1的命令爲什麼要加-o /dev/null?不加的話,會把響應也顯示出來,看起來不夠美觀了~

 

那圖1爲啥還要加-s命令呢?如果不加的話,會顯示下面的進度條信息↓

這個命令對於計算機網絡學的好的同學來說,簡直就是神器了,https://curl.haxx.se/docs/manpage.html這裏面,搜索-w,可以看到完整的參數,大家可以根據需求,添加到curl-time.txt文本中~,下面截取部分內容,供大家參考。

http_code The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer. In 7.18.2 the alias response_code was added to show the same info.

http_connect The numerical code that was found in the last response (from a proxy) to a curl CONNECT request. (Added in 7.12.4)

http_version The http version that was effectively used. (Added in 7.50.0)

 

num_connects Number of new connects made in the recent transfer. (Added in 7.12.3)

num_redirects Number of redirects that were followed in the request. (Added in 7.12.3)

 

 

得到http請求各個環節的耗時情況,就可以定位瓶頸所在,展開進一步的排查和優化了~

 

預告一下,下篇文章將會給大家介紹下時序數據庫openTSDB,敬請期待~

 

最後祝各位老鐵,小年快樂!

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章