动态php页面响应速度分析(ab命令),本地测试响应时间0.3ms/request(硬件条件充足)
test.php内容(经测试,如果test.php文件只有一个空标签,那么与有一个echo语句的测试效果基本一样):
<?php
echo 'a';
?>
测试用例1:1个并发量发送5000个请求,test.php页面为一个字符a,本地访问,服务器cpu,内存等硬件资源充足。
[root@iZ25ja2kaemZ ~]# ab -c 1 -n 100 http://testlocals.bestbeijing.top/test/test.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 testlocals.bestbeijing.top (be patient).....done
Server Software: Apache/2.2.15
Server Hostname: testlocals.bestbeijing.top
Server Port: 80
Document Path: /test/test.php
Document Length: 1 bytes
Concurrency Level: 1
Time taken for tests: 0.037 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 19300 bytes
HTML transferred: 100 bytes
Requests per second: 2704.97 [#/sec] (mean)
Time per request: 0.370 [ms] (mean)
Time per request: 0.370 [ms] (mean, across all concurrent requests)
Transfer rate: 509.82 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 0 0.1 0 1
Waiting: 0 0 0.0 0 0
Total: 0 0 0.1 0 1
Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 0
95% 0
98% 1
99% 1
100% 1 (longest request)
测试用例2:5000个并发量发送5000个请求,,平均每个请求耗时1.033ms。本地访问,可见耗时比1个并发量增长了大概3倍,说明服务器cpu,内存资源或web服务器apache配置等达到了瓶颈,需要优化web服务器配置,因为本地测试,一定不是带宽的问题,且配置了hosts,本地带宽很大。
[root@iZ25ja2kaemZ ~]# ab -c 5000 -n 5000 http://testlocals.bestbeijing.top/test/test.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 testlocals.bestbeijing.top (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests
Server Software: Apache/2.2.15
Server Hostname: testlocals.bestbeijing.top
Server Port: 80
Document Path: /test/test.php
Document Length: 1 bytes
Concurrency Level: 5000
Time taken for tests: 5.167 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 985844 bytes
HTML transferred: 5108 bytes
Requests per second: 967.73 [#/sec] (mean)
Time per request: 5166.742 [ms] (mean)
Time per request: 1.033 [ms] (mean, across all concurrent requests)
Transfer rate: 186.33 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 692 1117.5 99 3088
Processing: 10 556 1046.3 111 4014
Waiting: 0 536 1052.1 94 4010
Total: 109 1249 1684.0 206 5124
Percentage of the requests served within a certain time (ms)
50% 206
66% 347
75% 3108
80% 3175
90% 4500
95% 4553
98% 4614
99% 5121
100% 5124 (longest request)