hhvm vs php-fpm, 于drupal的站点中实测

下面用的是linode的20$一个月的配置 用上hhvm

[root@li407-44 blog]# ab -c 50 -n 10000 http://blog.sky-city.me/node/33
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.sky-city.me (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
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.6.0
Server Hostname:        blog.sky-city.me
Server Port:            80

Document Path:          /node/33
Document Length:        8063 bytes

Concurrency Level:      50
Time taken for tests:   110.027 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      85350000 bytes
HTML transferred:       80630000 bytes
Requests per second:    90.89 [#/sec] (mean)
Time per request:       550.134 [ms] (mean)
Time per request:       11.003 [ms] (mean, across all concurrent requests)
Transfer rate:          757.54 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       3
Processing:   170  549  85.9    548    1057
Waiting:      170  539  83.4    540    1056
Total:        170  549  85.9    548    1057

Percentage of the requests served within a certain time (ms)
  50%    548
  66%    581
  75%    604
  80%    619
  90%    658
  95%    693
  98%    734
  99%    764
 100%   1057 (longest request)

-------------分线--用上hhvm-----------------

 [root@li407-44 blog]# ab -c 50 -n 10000 http://blog.sky-city.me/boot.php
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.sky-city.me (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
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.6.0
Server Hostname:        blog.sky-city.me
Server Port:            80

Document Path:          /boot.php
Document Length:        3 bytes

Concurrency Level:      50
Time taken for tests:   48.707 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      3420000 bytes
HTML transferred:       30000 bytes
Requests per second:    205.31 [#/sec] (mean)
Time per request:       243.533 [ms] (mean)
Time per request:       4.871 [ms] (mean, across all concurrent requests)
Transfer rate:          68.57 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.7      0      28
Processing:    26  243  64.7    244     521
Waiting:       26  242  64.7    243     521
Total:         26  243  64.7    244     521

Percentage of the requests served within a certain time (ms)
  50%    244
  66%    264
  75%    278
  80%    290
  90%    319
  95%    354
  98%    392
  99%    411
 100%    521 (longest request)

-------------分线--用上hhvm-----------------

 [root@li407-44 blog]# ab -c 10 -n 200 http://blog.sky-city.me/boot.php
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.sky-city.me (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests


Server Software:        nginx/1.6.0
Server Hostname:        blog.sky-city.me
Server Port:            80

Document Path:          /boot.php
Document Length:        3 bytes

Concurrency Level:      10
Time taken for tests:   1.002 seconds
Complete requests:      200
Failed requests:        0
Write errors:           0
Total transferred:      68400 bytes
HTML transferred:       600 bytes
Requests per second:    199.54 [#/sec] (mean)
Time per request:       50.116 [ms] (mean)
Time per request:       5.012 [ms] (mean, across all concurrent requests)
Transfer rate:          66.64 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    13   49   9.8     49      91
Waiting:       13   49   9.8     49      91
Total:         13   49   9.8     49      91

Percentage of the requests served within a certain time (ms)
  50%     49
  66%     52
  75%     54
  80%     56
  90%     61
  95%     66
  98%     78
  99%     80
 100%     91 (longest request)

-------------分线--用php-fpm-----------------

[root@li407-44 blog]# ab -c 10 -n 200 http://blog.sky-city.me/boot.php
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking blog.sky-city.me (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests


Server Software:        nginx/1.6.0
Server Hostname:        blog.sky-city.me
Server Port:            80

Document Path:          /boot.php
Document Length:        3 bytes

Concurrency Level:      10
Time taken for tests:   16.338 seconds
Complete requests:      200
Failed requests:        0
Write errors:           0
Total transferred:      68800 bytes
HTML transferred:       600 bytes
Requests per second:    12.24 [#/sec] (mean)
Time per request:       816.904 [ms] (mean)
Time per request:       81.690 [ms] (mean, across all concurrent requests)
Transfer rate:          4.11 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   454  809 103.4    807    1168
Waiting:      454  809 103.4    807    1168
Total:        454  809 103.4    807    1168

Percentage of the requests served within a certain time (ms)
  50%    807
  66%    826
  75%    858
  80%    875
  90%    921
  95%    986
  98%   1146
  99%   1167
 100%   1168 (longest request)

-------------在thinkphp下面的测试结果--------------

->/mnt/app/thinkphp/Application git:(1706475*)>ab -c 100 -n 20000 http://thinkphp/index.php
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking thinkphp (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
Completed 18000 requests
Completed 20000 requests
Finished 20000 requests


Server Software:        nginx/1.1.19
Server Hostname:        thinkphp
Server Port:            80

Document Path:          /index.php
Document Length:        13 bytes

Concurrency Level:      100
Time taken for tests:   8.097 seconds
Complete requests:      20000
Failed requests:        0
Write errors:           0
Total transferred:      7560000 bytes
HTML transferred:       260000 bytes
Requests per second:    2470.13 [#/sec] (mean)
Time per request:       40.484 [ms] (mean)
Time per request:       0.405 [ms] (mean, across all concurrent requests)
Transfer rate:          911.83 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       3
Processing:    12   40   5.0     40      91
Waiting:       12   40   5.0     40      91
Total:         12   40   5.0     40      91

Percentage of the requests served within a certain time (ms)
  50%     40
  66%     41
  75%     42
  80%     42
  90%     45
  95%     47
  98%     52
  99%     59
 100%     91 (longest request)

运用hhvm, drupal的性能提升20倍! hhvm用于thinkphp, 并发竟然可以接近2500! 1、CPU密集型测试 drupal的功能很多是通过递归实现,hhvm是递归提升的速度是非常大的,或许这就是提升20倍速度最主要的原因。

<?php
function fib($n)
{
    if ($n 
➜  hhvm_test  time php t1.php 
fib(36) = 14930352
php t1.php  23.69s user 0.01s system 99% cpu 23.852 total
➜  hhvm_test  time hhvm t1.php 
fib(36) = 14930352
hhvm t1.php  0.25s user 0.02s system 97% cpu 0.283 total
➜  hhvm_test

2、内存密集型测试

<?php
ini_set('memory_limit','2024M');
 
$arr = array();
for($i = 0; $i < 2000000 ; $i++) {
    $arr[$i] = $i;  
}
 
$arr2 = array();
 
foreach($arr as $val){
    $arr2[] = $val . $val;
}
?>
➜  hhvm_test  time php t2.php
php t2.php  5.42s user 0.54s system 99% cpu 6.000 total
➜  hhvm_test  time hhvm t2.php
hhvm t2.php  1.05s user 0.14s system 98% cpu 1.213 total
➜  hhvm_test