因 HHVM 会篡改 phpinfo()
函数输出结果,因此使用最基本的 echo 'Hello World!';
进行测试。
在 OS X 10.9.3 使用 VirtualBox 4.3.12 r93733 创建虚拟机,配置如下:
# uname -a
Linux sandbox-1 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3+deb7u2 x86_64 GNU/Linux
# dpkg -l
||/ Name Version Architecture
+++-======================================-========================-============
ii nginx-full 1.4.6-1~dotdeb.1 amd64
ii php5-fpm 5.5.10-1~dotdeb.1 amd64
ii hhvm 3.1.0~wheezy amd64
# free -h
total
Mem: 496M
Swap: 487M
# # grep 'processor\s*:' /proc/cpuinfo | wc -l
2
# ulimit -n
65535
# cat /etc/nginx/nginx.conf
worker_processes 2;
worker_connections 1024;
keepalive_timeout 15;
# cat /etc/php5/fpm/pool.d/www.conf
listen.backlog = 4096
pm = static
pm.max_children = 4
$ ab -V
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
统一使用 ab -c 100 -n 10000 http://127.0.0.1/
度量。
每次测试前,确认服务为新启动,且网络链接情况恢复正常。
-
TCP
Time taken for tests: 5.366 seconds Failed requests: 0 Write errors: 0 Requests per second: 1863.51 [#/sec] (mean) Time per request: 53.662 [ms] (mean) Connection Times (ms) min mean[+/-sd] median max Connect: 0 3 4.5 1 24 Processing: 5 50 13.4 50 98 Waiting: 5 48 13.7 48 98 Total: 13 53 11.3 53 98 Percentage of the requests served within a certain time (ms) 50% 53 75% 58 90% 66 98% 84 100% 98 (longest request)
-
Unix Socket
Time taken for tests: 4.231 seconds Failed requests: 0 Write errors: 0 Requests per second: 2363.37 [#/sec] (mean) Time per request: 42.312 [ms] (mean) Connection Times (ms) min mean[+/-sd] median max Connect: 0 7 5.6 6 27 Processing: 4 35 10.5 34 83 Waiting: 4 32 10.9 31 83 Total: 14 42 8.0 41 83 Percentage of the requests served within a certain time (ms) 50% 41 75% 47 90% 54 98% 60 100% 83 (longest request)
为真实展现 HHVM 处理能力,按照其官方文档,在 Nginx 配置中启用了 fastcgi_keep_conn 指令。
-
TCP
Time taken for tests: 7.788 seconds Failed requests: 0 Write errors: 0 Requests per second: 1284.09 [#/sec] (mean) Time per request: 77.876 [ms] (mean) Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 1.0 0 16 Processing: 14 77 5.7 76 109 Waiting: 14 77 5.7 76 109 Total: 29 78 5.6 77 113 Percentage of the requests served within a certain time (ms) 50% 77 75% 80 90% 85 98% 90 100% 113 (longest request)
-
Unix Socket
Time taken for tests: 7.615 seconds Failed requests: 0 Write errors: 0 Requests per second: 1313.28 [#/sec] (mean) Time per request: 76.145 [ms] (mean) Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 1.1 1 13 Processing: 53 75 5.9 75 117 Waiting: 53 74 5.8 74 116 Total: 54 76 6.2 76 125 Percentage of the requests served within a certain time (ms) 50% 76 75% 79 90% 82 98% 93 100% 125 (longest request)
PHP-FPM | HHVM | |||
---|---|---|---|---|
TCP | Unix Socket | TCP | Unix Socket | |
Requests per second [#/sec] | 1863.51 | 2363.37 | 1284.09 | 1313.28 |
Time per request [ms] | 53.662 | 42.312 | 77.876 | 76.145 |
... 98% [ms] | 84 | 60 | 90 | 93 |