Centos7 curl请求速度慢的问题以及解决方案

在更换Centos7 服务器之后,发现接口响应时间变为原来的3倍。在排除redis、mysql连接时间的问题后,由同事发现是curl访问速度变慢导致的。解决方案为执行以下命令:

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系统分析curl请求时间
 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 写到垃圾回收站[ /dev/null]
-s:去掉所有状态
-w:按照后面的格式写出rt
time_namelookup:DNS 解析域名的时间
time_commect:client和server端建立TCP 连接的时间
time_starttransfer:从client发出请求;到web的server 响应第一个字节的时间
time_total:client发出请求;到web的server发送会所有的相应数据的时间
speed_download:下周速度 单位 byte/s

你可能感兴趣的:(Centos7 curl请求速度慢的问题以及解决方案)