V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
branchzero
V2EX  ›  PHP

让我奔歌一下 HHVM,实在是良器

  •  
  •   branchzero · 2014-11-05 22:08:43 +08:00 · 4649 次点击
    这是一个创建于 3462 天前的主题,其中的信息可能已经有所发展或是发生改变。

    奔歌之前先贬一贬
    HHVM手动编译太不友好了,如果你本身的环境不是纯净的环境,用过yum安装过其中的一些必须要求的库的话,就不要手动编译了,各种报错让你感动。自行编译一些库的话,也有坑,一些库的版本不能低也不能高,要求实在太多了,排了两天错才搞定编译。所以强烈建议少折腾,直接用官方提供的预编译包!!!

    不过还是挺令我欣喜的
    简单benchmark一下,同样跑一个Typecho的话

    下面是HHVM+Nginx的结果

    [root@main hhvm]# ab -n 10000 test_site
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking test_site (be patient)
    Completed 1000 requests
    Completed 2000 requests
    Completed 3000 requests
    Completed 4000 requests
    Completed 5000 requests
    Completed 6000 requests
    Completed 7000 requests
    Completed 8000 requests
    ^C

    Server Software: Tengine/2.0.2
    Server Hostname: test_site
    Server Port: 80
    Document Path: /
    Document Length: 24568 bytes
    Concurrency Level: 1
    Time taken for tests: 230.869 seconds

    Complete requests: 8646

    Failed requests: 0
    Write errors: 0
    Total transferred: 214740702 bytes
    HTML transferred: 212414928 bytes
    Requests per second: 37.45 [#/sec] (mean)
    Time per request: 26.702 [ms] (mean)
    Time per request: 26.702 [ms] (mean, across all concurrent requests)
    Transfer rate: 908.34 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 0 0.0 0 0
    Processing: 26 27 0.8 27 81
    Waiting: 26 26 0.8 26 81
    Total: 26 27 0.8 27 81

    Percentage of the requests served within a certain time (ms)
    50% 27
    66% 27
    75% 27
    80% 27
    90% 27
    95% 27
    98% 27
    99% 28
    100% 81 (longest request)

    下面是Php-fpm+Nginx

    [root@main hhvm]# ab -n 10000 test_site
    This is ApacheBench, Version 2.3 <$Revision: 655654 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking test_site (be patient)
    Completed 1000 requests
    Completed 2000 requests
    Completed 3000 requests
    Completed 4000 requests
    Completed 5000 requests
    Completed 6000 requests
    Completed 7000 requests
    Completed 8000 requests
    ^C

    Server Software: Tengine/2.0.2
    Server Hostname: test_site
    Server Port: 80

    Document Path: /
    Document Length: 24568 bytes

    Concurrency Level: 1
    Time taken for tests: 475.457 seconds
    Complete requests: 8475
    Failed requests: 2
    (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
    Write errors: 0
    Total transferred: 210713865 bytes
    HTML transferred: 208213740 bytes
    Requests per second: 17.82 [#/sec] (mean)
    Time per request: 56.101 [ms] (mean)
    Time per request: 56.101 [ms] (mean, across all concurrent requests)
    Transfer rate: 432.79 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 0 0.0 0 0
    Processing: 56 56 0.3 56 68
    Waiting: 55 56 0.3 56 67
    Total: 56 56 0.3 56 68

    Percentage of the requests served within a certain time (ms)
    50% 56
    66% 56
    75% 56
    80% 56
    90% 56
    95% 56
    98% 57
    99% 57
    100% 68 (longest request)

    测试期间,CPU占用大致相当,同样的时间HHVM几乎完成了两倍的请求
    Nice!

    12 条回复    2014-11-12 10:03:04 +08:00
    RemRain
        1
    RemRain  
       2014-11-05 22:27:50 +08:00
    这跑的什么程序啊,qps 37,是各种计算么
    vibbow
        2
    vibbow  
       2014-11-05 22:27:54 +08:00
    估计不用Nginx的话性能会更高点...
    zjgood
        3
    zjgood  
       2014-11-05 22:32:18 +08:00 via Android
    varnish应该会更棒。。。phpng也不错,hhvm太吃内存了
    lincanbin
        4
    lincanbin  
       2014-11-05 22:34:07 +08:00
    CentOS 5.1,无缘HHVM了。
    只能下次迁VPS的时候再换上了。
    RemRain
        5
    RemRain  
       2014-11-05 22:39:41 +08:00
    感觉 HHVM 官网的测试有些水分,之前我测过 yii 框架下简单的 controller/action,带一次memcache 请求。

    其中 nginx + php-fpm(5.4),开 APC 扩展,单机 QPS 2.2w 左右,性能瓶颈只在网卡。
    HHVM,单机 QPS 也在 2.2w 左右,比 php-fpm 略高,也是性能在网卡。

    另外看过一个老外的 blog,也是说 HHVM 没那么绚丽,测试得到的数据和我差不多。而且他测的 php5.6 QPS 甚至比 HHVM 高。

    印象中 HHVM 只对计算类有用,官网的测试数据都是各种计算类的。但实际开发中通常不会把复杂计算放到请求处理中,都是业务逻辑外加数据库、redis 等各种操作,HHVM 的优点似乎发挥不出来。
    chenwl
        6
    chenwl  
       2014-11-05 23:07:02 +08:00
    也就在计算性能上有优势,扯到后端业务上性能的提升只是一点点,不是一倍。期待phpng的出世。
    superwbd
        7
    superwbd  
       2014-11-05 23:57:34 +08:00
    这货的兼容性令人蛋碎。。。


    之前尝试把几个站搬到HHVM上,各种报错,不得不回滚。。。悲催 只能等HHVM完善了。
    princeofwales
        8
    princeofwales  
       2014-11-06 08:22:00 +08:00
    HHVM容易崩溃,然后502,不得不放个crontab监控进程

    听说phpng更牛,下次迁移vps的时候再试
    tabris17
        9
    tabris17  
       2014-11-06 09:39:11 +08:00
    没有数量级的差异,还是算了吧
    tabris17
        10
    tabris17  
       2014-11-06 09:39:40 +08:00
    而且HHVM对PHP的动态特性支持不好
    tczzjin
        11
    tczzjin  
       2014-11-06 16:52:38 +08:00
    是是phpng吧,现在在php-src的git库的master分支就是了,性能确实不错,和自己的php的兼容性几乎完美,不过部分插件,redis啥的还不支持
    tabris17
        12
    tabris17  
       2014-11-12 10:03:04 +08:00
    phpng是php7吧,早了。有得好等了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1084 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:34 · PVG 02:34 · LAX 11:34 · JFK 14:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.