Home  >  Article  >  Backend Development  >  curl_exec执行时间为啥总是5秒

curl_exec执行时间为啥总是5秒

WBOY
WBOYOriginal
2016-06-13 13:26:501366browse

curl_exec执行时间为什么总是5秒
我使用curl访问另一个网站的网址,其实这另一个网站是同一个服务器和IP,只是域名不同。而且都是unxix的,
采用同步执行curl_exec,中共耗时不多不少,刚好5秒。用此函数访问另外网站则正常、
我很纳闷。为什么刚好5秒呢?而且这绝不是服务器速度和网速,那边的程序就一条语句 echo "OK" ;
我在浏览器直接调用其网址也是不需要时间的。
请求解答。谢谢

------解决方案--------------------
说明5秒的那个域名解析DNS太慢了。
------解决方案--------------------
一是,你的代码
二是,你的目的站
三,你的本地电脑,
先把二,三,换成其他 试试。粘出你的代码。
------解决方案--------------------
大约看明白什么意思了 
 root 打开 /etc/nsswitch.conf

里面大概有一行是
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

注释掉(在前面添加一个#)
然后在下面增加一行
hosts: files dns

保存.
然后试吧,祝你好运...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn