|
|
原出处:http://www.livid.cn/doc_view.php?doc_id=1159
测试所用服务器的硬件配置如下。
* CPU - Pentium 4 XEON 2.8G EM64T FSB800 x 2
* RAM - 2G DDR-2 ECC
* HDD - UltraSCSI 320 146G Maxtor ATLAS RPM15K x 2
测试所用服务器的软件配置如下。
* OS - Debian GNU/Linux 2.4.29
* WWW - Apache Web Server 2.0.53
* PHP - PHP 4.3.10
* MYSQL - MySQL 4.0.24
本测试报告主要描述我个人的两个 LAMP 网站 http://www.liuxin.cn/ 和 http://www.lividot.org/ 在使用和未使用 eAccelerator 时的性能对比,所使用的 eAccelerator 版本为 0.9.2a,另外为了和静态页面的性能进行对比,使用了 http://www.yahoo.com.cn/ 的首页文件。另外需要进行说明的是,本测试中所涉及的所有域名都使用 /etc/hosts 文件解析到了 127.0.0.1,因此没有网络带宽限制。
测试使用 ApacheBench 进行。
测试情况 1 - 不使用 eAccelerator 时的情况
http://www.liuxin.cn/index.php 动态页面测试结果
vik:/# ab -n 10000 -c 100 http://www.liuxin.cn/index.php
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.liuxin.cn (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
Finished 10000 requests
Server Software: Apache/2.0.53
Server Hostname: www.liuxin.cn
Server Port: 80
Document Path: /index.php
Document Length: 15128 bytes
Concurrency Level: 100
Time taken for tests: 13.188883 seconds
Complete requests: 10000
Failed requests: 2084
(Connect: 0, Length: 2084, Exceptions: 0)
Write errors: 0
Total transferred: 150001513 bytes
HTML transferred: 147875871 bytes
Requests per second: 758.21 [#/sec] (mean)
Time per request: 131.889 [ms] (mean)
Time per request: 1.319 [ms] (mean, across all concurrent requests)
Transfer rate: 11106.70 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 31 20.8 31 101
Processing: 7 98 74.2 81 1430
Waiting: 1 62 60.6 48 1394
Total: 19 130 73.9 117 1498
Percentage of the requests served within a certain time (ms)
50% 117
66% 128
75% 143
80% 150
90% 192
95% 245
98% 334
99% 410
100% 1498 (longest request)
http://www.lividot.org/index.php 动态页面测试结果
vik:/usr/share/php4# ab -n 10000 -c 100 http://www.lividot.org/index.php
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.lividot.org (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
Finished 10000 requests
Server Software: Apache/2.0.53
Server Hostname: www.lividot.org
Server Port: 80
Document Path: /index.php
Document Length: 54556 bytes
Concurrency Level: 100
Time taken for tests: 58.393872 seconds
Complete requests: 10000
Failed requests: 9171
(Connect: 0, Length: 9171, Exceptions: 0)
Write errors: 0
Total transferred: 400125463 bytes
HTML transferred: 398014333 bytes
Requests per second: 171.25 [#/sec] (mean)
Time per request: 583.939 [ms] (mean)
Time per request: 5.839 [ms] (mean, across all concurrent requests)
Transfer rate: 6691.58 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 51 54.2 34 282
Processing: 27 526 851.1 406 10948
Waiting: 0 240 579.3 137 9255
Total: 37 577 847.4 459 10950
Percentage of the requests served within a certain time (ms)
50% 459
66% 548
75% 602
80% 649
90% 789
95% 954
98% 1290
99% 7951
100% 10950 (longest request)
http://www.liuxin.cn/yahoo.html 静态页面测试结果
vik:/# ab -n 10000 -c 100 http://www.liuxin.cn/yahoo.html
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.liuxin.cn (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
Finished 10000 requests
Server Software: Apache/2.0.53
Server Hostname: www.liuxin.cn
Server Port: 80
Document Path: /yahoo.html
Document Length: 31846 bytes
Concurrency Level: 100
Time taken for tests: 1.457515 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 321623785 bytes
HTML transferred: 318611076 bytes
Requests per second: 6860.99 [#/sec] (mean)
Time per request: 14.575 [ms] (mean)
Time per request: 0.146 [ms] (mean, across all concurrent requests)
Transfer rate: 215493.49 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 3
Processing: 2 13 1.3 14 20
Waiting: 1 12 1.0 12 19
Total: 5 13 1.2 14 20
Percentage of the requests served within a certain time (ms)
50% 14
66% 14
75% 14
80% 14
90% 15
95% 15
98% 16
99% 16
100% 20 (longest request)
测试情况 2 - 使用 eAccelerator 时的情况
http://www.liuxin.cn/index.php 动态页面测试结果
vik:/# ab -n 10000 -c 100 http://www.liuxin.cn/index.php
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.liuxin.cn (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
Finished 10000 requests
Server Software: Apache/2.0.53
Server Hostname: www.liuxin.cn
Server Port: 80
Document Path: /index.php
Document Length: 15128 bytes
Concurrency Level: 100
Time taken for tests: 9.470512 seconds
Complete requests: 10000
Failed requests: 1652
(Connect: 0, Length: 1652, Exceptions: 0)
Write errors: 0
Total transferred: 153798748 bytes
HTML transferred: 151691818 bytes
Requests per second: 1055.91 [#/sec] (mean)
Time per request: 94.705 [ms] (mean)
Time per request: 0.947 [ms] (mean, across all concurrent requests)
Transfer rate: 15859.12 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 5 8.5 0 48
Processing: 16 88 25.2 89 564
Waiting: 1 79 24.4 83 538
Total: 41 93 23.3 91 576
Percentage of the requests served within a certain time (ms)
50% 91
66% 96
75% 99
80% 102
90% 110
95% 121
98% 147
99% 174
100% 576 (longest request)
http://www.lividot.org/index.php 动态页面测试结果
vik:/# ab -n 10000 -c 100 http://www.lividot.org/index.php
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.lividot.org (be patient)
vik:/# ab -n 10000 -c 100 http://www.lividot.org/index.php
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.lividot.org (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
Finished 10000 requests
Server Software: Apache/2.0.53
Server Hostname: www.lividot.org
Server Port: 80
Document Path: /index.php
Document Length: 54556 bytes
Concurrency Level: 100
Time taken for tests: 51.7776 seconds
Complete requests: 10000
Failed requests: 7963
(Connect: 0, Length: 7963, Exceptions: 0)
Write errors: 0
Total transferred: 417561682 bytes
HTML transferred: 415452022 bytes
Requests per second: 196.05 [#/sec] (mean)
Time per request: 510.078 [ms] (mean)
Time per request: 5.101 [ms] (mean, across all concurrent requests)
Transfer rate: 7994.37 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 40 47.1 23 263
Processing: 27 465 714.0 357 8591
Waiting: 0 212 544.0 122 7338
Total: 50 506 710.4 399 8592
Percentage of the requests served within a certain time (ms)
50% 399
66% 475
75% 533
80% 568
90% 710
95% 872
98% 1150
99% 6780
100% 8592 (longest request)
http://www.liuxin.cn/yahoo.html 静态页面测试结果
vik:/# ab -n 10000 -c 100 http://www.liuxin.cn/yahoo.html
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.liuxin.cn (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
Finished 10000 requests
Server Software: Apache/2.0.53
Server Hostname: www.liuxin.cn
Server Port: 80
Document Path: /yahoo.html
Document Length: 31846 bytes
Concurrency Level: 100
Time taken for tests: 1.456759 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 321614972 bytes
HTML transferred: 318603166 bytes
Requests per second: 6864.55 [#/sec] (mean)
Time per request: 14.568 [ms] (mean)
Time per request: 0.146 [ms] (mean, across all concurrent requests)
Transfer rate: 215599.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 3
Processing: 2 13 1.2 14 19
Waiting: 1 12 0.9 12 17
Total: 5 13 1.2 14 19
Percentage of the requests served within a certain time (ms)
50% 14
66% 14
75% 14
80% 14
90% 15
95% 15
98% 15
99% 16
100% 19 (longest request)
测试结论
1,eAccelerator 模块加载与否对于服务器提供静态内容的能力没有影响。
2,各站点在使用了 eAccelerator 的性能都有提升。
http://www.liuxin.cn/index.php,758.21 -> 1055.91,提高 39.26%
http://www.lividot.org/index.php,171.25 -> 196.05,提高 14.48%
3,总结
能够得到这样的测试结果,并不完全是 eAccelerator 带来的好处,与程序本身的编写也有非常大的关系。
http://www.liuxin.cn/index.php 是纯粹由固定结果的 SELECT 查询构建的页面,因此其性能的提高,与 MySQL 的缓冲也有非常巨大的关系。
而 http://www.lividot.org/index.php 的情况就大不一样,其中大量使用到了 URL Rewrite,XML RPC,Shell Execution 等技术,而且其页面中还包含了数十个数据查询,及大量复杂的分页及错误检测逻辑,因此其基础性能和提高值相对而言就比较有限。
eAccelerator 作为一种开源的 PHP 加速方案,能够有如此表现,已经非常让人惊喜。考虑到 Zend Platform 的双 CPU 授权的售价高达 1495 美元一年,eAccelerator 已经非常超值了。
ApacheBench(以下简称 ab)的测试数据的 requests per second (以下简称 rps)一项是指每秒服务器返回的页面数,该数量并不完全代表服务器的峰值负担,因为在真正的实际环境中,服务器还需要对诸如图片,CSS 这样的内容进行响应。因此个人认为,在使用 ab 的测试结果对程序进行优化时,可以像这样计算,假设你希望你的一个站点的首页能够支撑一天 100 万的 pageviews,那么用 1000000 / 86400 = 11.574074,考虑到首页流量至多占到整个站点流量的 40%,那么需要将此数字乘以 2.5,则得到 28.935185,为了能够应付峰值时候的流量,需要将此数字再乘以 3,则得到 86.805552。
最终我们得到一个 rps 值 86.805552,该数字表示,如果你希望你的一个站点能够达到 1000000 pageviews 一天且能够轻松面对业务高峰的话,那么首页在 ab 里头测试得到的 rps 必须大于等于 86,同时也表示,只要 rps 大于等于 86,你在页面上加任何功能都没有问题。
by ~Livid - [ 技术本质 ] - 2005-04-06 03:28:01 - 37 |
|