php - Vagrant+Ubuntu 14.04+Nginx+HHVM = 缓慢+崩溃

标签 php ubuntu nginx vagrant hhvm

根据我的 last question ,我试图通过在 HHVM 下运行 Laravel 来加速它。

这需要我将我的服务器更新到 64 位,所以我现在正在运行 Trusty64。我通过 deb 包安装了 HHVM 和 Nginx。我不确定我的 nginx 配置是否正确,我从网上抓取了这个:

server {
    listen 80 default_server;

    root /vagrant/public;
    index index.php index.html index.htm;

    server_name localhost;

    access_log /var/log/nginx/localhost.laravel-access.log;
    error_log  /var/log/nginx/locahost.laravel-error.log error;

    charset utf-8;

    location / {
        try_files \$uri \$uri/ /index.php?\$query_string;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }

    error_page 404 /index.php;

    include /etc/nginx/hhvm.conf;  # The HHVM Magic Here
}

而且我的网站在我点击它的前几次确实加载了。它现在的加载时间是内置 PHP 服务器的两倍多。刷新几次后,页面完全停止加载,nginx 出现 504 网关超时,我无法再通过 SSH 连接到我的服务器,而 vagrant 需要几分钟才能关闭。无论它在做什么,它都会完全杀死我的服务器。

我听说 HHVM 使用某种 JIT 并需要预热,然后在加载几次后启动?这可能是破坏我的服务器的原因吗?我该如何解决?

最佳答案

帖子更新:我必须食言!!!! 我将 laravel 代码从共享虚拟框文件夹移动到非共享目录,现在一旦 JIT 启动,HHVM 会在不到 10 毫秒的时间内加载 laravel 欢迎屏幕。

有一个启动配置设置指示在 HHVM JIT 启动之前所需的请求数。

这是我用于我的 HHVM 的 ini 文件:

 pid = /var/run/hhvm/pid

 hhvm.server.file_socket=/var/run/hhvm/hhvm.sock
 hhvm.server.type = fastcgi
 hhvm.server.default_document = index.php
 hhvm.log.level = Warning
 hhvm.log.always_log_unhandled_exceptions = true
 hhvm.log.runtime_error_reporting_level = 8191
 hhvm.log.use_log_file = true
 hhvm.log.file = /var/log/hhvm/error.log
 hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
 hhvm.mysql.typed_results = false

 hhvm.eval.jit_warmup_requests = 1

jit_warmup_requests = 1 表示优化前重新加载一次,但您可以将其设置为 0 以使其立即启动。我想如果没有指定,它就像 10请求或其他东西。

无论如何,我在使用共享文件夹的 VirtualBox 图像上使用与您相同的设置,nginx、hhvm 3.0.1、laravel、Ubuntu 14。我将同一个共享文件夹与运行 PHP-FPM5.5 的第二个图像一起使用。 PHP-5.5 在 50 毫秒左右加载 Laravel“您已到达”页面,而 HHVM 版本大约为 250 毫秒——性能远低于预期。我将测试在非共享目录中运行代码,但我怀疑这是问题所在。

我怀疑这与必须在运行时与编译时评估的代码量有关。我知道如果我运行的代码有很多神奇的方法和可变变量,HHVM 就不会很出色。 Laravel 有一些时髦的自动加载正在进行以实现它隐藏 namespace 等,这可能会产生一些影响,但我需要更深入地了解这一点。

我在我的 nginx 配置文件中有这个来将脚本传递给 HHVM(注意我使用套接字,而不是 TCP 并且还没有使用 hack。)

      location ~ \.php$ {
            fastcgi_pass unix:/var/run/hhvm/hhvm.sock;

            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include         fastcgi_params;
         }

关于php - Vagrant+Ubuntu 14.04+Nginx+HHVM = 缓慢+崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23305964/

相关文章:

php - Drupal 表单提交,表单 after_build

c++ - Linux 可执行参数选项卡完成

ruby-on-rails - 独 Angular 兽 worker 超时

file - 在 Nginx 上配置缓存 css/js 文件

python - Flask 或 Pyramid 中的简单网络 UDP 监听

php - 返回不同表中两个 MySQL 列之间的差异

php - <a> 标签不工作?

ubuntu - 未找到 lgfortran

javascript - ReactJS部署应用程序错误无法复制到剪贴板: Command failed: xsel --clipboard --input

php - 事件流的智能 MySQL GROUP BY