在更換Centos7 服務(wù)器之后剑令,發(fā)現(xiàn)接口響應(yīng)時(shí)間變?yōu)樵瓉?lái)的3倍先馆。在排除redis红氯、mysql連接時(shí)間的問(wèn)題后,由同事發(fā)現(xiàn)是curl訪問(wèn)速度變慢導(dǎo)致的嚷辅。解決方案為執(zhí)行以下命令:
mkdir /tmp/libcurl
cd /tmp/libcurl
wget http://dl.fedoraproject.org/pub/archive/fedora/linux/updates/19/x86_64/curl-7.29.0-27.fc19.x86_64.rpm
wget http://dl.fedoraproject.org/pub/archive/fedora/linux/updates/19/x86_64/libcurl-7.29.0-27.fc19.x86_64.rpm
wget http://dl.fedoraproject.org/pub/archive/fedora/linux/updates/19/x86_64/libcurl-devel-7.29.0-27.fc19.x86_64.rpm
yum -y install *.fc19.x86_64.rpm
linux系統(tǒng)分析curl請(qǐng)求時(shí)間
curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer}::%{time_total}::%{speed_download}"\n" 'http://www.baidu.com'
其中
o:把curl 返回的html簿姨、js 寫(xiě)到垃圾回收站[ /dev/null]
-s:去掉所有狀態(tài)
-w:按照后面的格式寫(xiě)出rt
time_namelookup:DNS 解析域名的時(shí)間
time_commect:client和server端建立TCP 連接的時(shí)間
time_starttransfer:從client發(fā)出請(qǐng)求;到web的server 響應(yīng)第一個(gè)字節(jié)的時(shí)間
time_total:client發(fā)出請(qǐng)求簸搞;到web的server發(fā)送會(huì)所有的相應(yīng)數(shù)據(jù)的時(shí)間
speed_download:下周速度 單位 byte/s