机器:Dell Latitude D610 奔腾M 1.73G单核 内存:DDR2-533 2G
系统:Kubuntu 8.10 官方源升级至本日
PHP:PHP 5.2.6-2ubuntu4 with Suhosin-Patch 0.9.6.2
Apache :2.2.9-7ubuntu3 (PHP模块)
Cherokee:0.11.5(PHP-FastCGI)
*两者PHP配置以及调用的模块完全相同。
以上软件包均来自官方源,其中除Cherokee最大执行时间由默认的三秒调整为一万秒,FastCGI访问模式更改为socket,别的都再没动。
测试页面为一个PHPINFO(),测试时两个Web Serveer只开启其中之一,使用相同的参数 -n 1000 -c 100。
Apache测试结果:
ruyi7952
@D610:~$ ab
-n
1000
-c
100 http:
//localhost
/phpinfo.php
引用
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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.2.9
Server Hostname: localhost
Server Port: 80
Document Path: /phpinfo.php
Document Length: 83211 bytes
Concurrency Level: 100
Time taken for tests: 11.999 seconds
Complete requests: 1000
Failed requests: 39
(Connect: 0, Receive: 0, Length: 39, Exceptions: 0)
Write errors: 0
Total transferred: 83599043 bytes
HTML transferred: 83358609 bytes
Requests per second: 83.34 [#/sec] (mean)
Time per request: 1199.936 [ms] (mean)
Time per request: 11.999 [ms] (mean, across all concurrent requests)
Transfer rate: 6803.67 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 98 85.4 70 357
Processing: 287 982 967.8 822 8107
Waiting: 14 400 127.1 403 1164
Total: 357 1080 957.9 895 8180
Percentage of the requests served within a certain time (ms)
50% 895
66% 992
75% 1029
80% 1058
90% 1130
95% 1204
98% 5583
99% 6726
100% 8180 (longest request)
结果概要:请求1000次,失败39次,平均每秒处理83.34个请求。
Cherokee测试结果:
ab
-n
1000
-c
100 http:
//localhost:
8080
/phpinfo.php
引用
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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Cherokee/0.11.5
Server Hostname: localhost
Server Port: 8080
Document Path: /phpinfo.php
Document Length: 81300 bytes
Concurrency Level: 100
Time taken for tests: 7.019 seconds
Complete requests: 1000
Failed requests: 884
(Connect: 0, Receive: 0, Length: 884, Exceptions: 0)
Write errors: 0
Total transferred: 81479704 bytes
HTML transferred: 81301704 bytes
Requests per second: 142.47 [#/sec] (mean)
Time per request: 701.893 [ms] (mean)
Time per request: 7.019 [ms] (mean, across all concurrent requests)
Transfer rate: 11336.49 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 10.5 0 43
Processing: 36 666 133.3 678 879
Waiting: 21 659 132.6 672 855
Total: 48 670 126.0 678 879
Percentage of the requests served within a certain time (ms)
50% 678
66% 685
75% 702
80% 714
90% 766
95% 850
98% 855
99% 858
100% 879 (longest request)
结果概要:请求1000次,失败884次,平均每秒处理142.47次请求。
我 的不完整结论:Cherokee 看似每秒可处理的请求数量142.47次要高于Apache2的每秒83.34次,但是Cherokee在1000次请求中有884次失败,也就是说在整 个测试过程中88.40%的时间Cherokee处于罢工“状态”,等于每秒有125.94348次请求压根没有完成!我们用147.47* (1-0.884) 计算,可以得出其有效请求处理量仅为16.52652次。我个人建议在大负荷下暂时不要选择Cherokee做PHP+MySQL搭配的动态网站。
后话,我单独测试了,PHP+MySQL的性能表现,在Cherokee中,即便是调用了tcmalloc库,整体性能也只能和没有调用tcmalloc库时候的apache+php+mysql持平,甚至更低一些。