Phantomjs 加载页面缓慢 [英] Phantomjs loads pages slowly

查看:68
本文介绍了Phantomjs 加载页面缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 phantomjs 的新手,在标准的 centOS 服务器上尝试它(安装了 httpd 等,但除了名称服务器设置为 8.8.8.8 和 8.8.4.4 之外没有修改设置).

I'm new into phantomjs, trying it on a standard centOS server (with httpd etc installed, but no modified settings apart from nameservers set to 8.8.8.8 and 8.8.4.4).

我正在使用默认的 loadspeed.js 文件(被重命名).但是,页面速度似乎非常慢.这是一个例子:

I'm using the default loadspeed.js file (be it renamed). However, page speeds appear to be extremely slow. Here's an example:

$ phantomjs phantomjs.js  http://www.google.com/
starting
Loading time 90928 msec

$ phantomjs phantomjs.js http://173.194.67.138/ #(one of google's public ips)
starting
Loading time 30204 msec

当我在服务器上加载任何 url 时(例如 http://something.be ),加载时间为 141 毫秒:

When I load any url on the server (such as http://something.be ), loadtime is 141msec:

 $ phantomjs phantomjs.js http://something.be
 starting
 Loading time 141 msec

有没有人知道是什么导致我的连接这么慢?连接本身很好,wget 需要几秒钟来下载几个 MB 的文件.

Does anyone have a clue what causes my connection to be this slow? The connection itself is fine, wget takes seconds to download a file of several MB.

另外,当我在 OSX 上为 Google 本地运行完全相同的脚本时,输出如下:

Also, when I run the exact same script on OSX locally for Google, this is the output:

 phantomjs phantomjs.js http://google.com/
 starting
 Loading time 430 msec

推荐答案

找到了 - 似乎 ipv6 是罪魁祸首.

Found it - seems like ipv6 was the culprit.

我通过运行以下命令暂时禁用了它:

I disabled it temporarily by running the following:

echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6

测试确认:

$ phantomjs phantomjs.js http://google.com
starting
Loading time 230 msec

这篇关于Phantomjs 加载页面缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆