测试环境:
操作系统:CentOS release 6.6 (Final)
Apache性能测试工具ab:This is ApacheBench, Version 2.3
1.apache自带的压力测试软件ab测试。
2.apache benchmark简称ab,ab是apache基准测试工具。
3.yum -y install httpd-tools #可以单独安装ab
4.ab压力测试时,可能要创建很多测试文件并删除,文件过多系统就会报错,修改如下:ulimit –n 3600
ab测试常用命令
格式: ./ab[options][http://]hostname[:port]/path
-n 测试会话中所执行的请求个数,默认时,仅执行一个请求
-c 一次产生的请求个数。默认是一次一个
-t 测试所进行的最大秒数
-v 设置显示信息的详细程度,参数可能由负数到正数,值越大,显示的信息更详细。
ab测试举例一
[[email protected]/]# ab -c 100 -n 1000 http://117.40.239.9/bbs/forum.php
Thisis ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensedto The Apache Software Foundation, http://www.apache.org/
Benchmarking117.40.239.9 (be patient)
Completed100 requests
Completed200 requests
Completed300 requests
Completed400 requests
Completed500 requests
Completed600 requests
Completed700 requests
Completed800 requests
Completed900 requests
Completed1000 requests
Finished1000 requests
ServerSoftware: Apache/2.2.15 #web服务器软件
ServerHostname: 117.40.239.9 #服务器IP地址
Server Port: 80 #服务器端口
DocumentPath: /bbs/forum.php #访问路径
DocumentLength: 50602 bytes #访问文件的大小
ConcurrencyLevel: 100 #并发请求数,即同一时间访问的人数
Time taken for tests: 43.837 seconds #响应时间
Completerequests: 1000 #总共响应请求次数
Failedrequests: 1 #失败请求次数
(Connect: 0, Receive: 0, Length: 1,Exceptions: 0)
Writeerrors: 0 #失败写入次数
Totaltransferred: 51367791 bytes #传输的总数据量
HTMLtransferred: 50935667 bytes #html页面大小
Requestsper second: 22.81 [#/sec] (mean) #每秒支持多少人访问
Timeper request: 4383.664 [ms] (mean) #满足一个请求花费的总时间
Timeper request: 43.837 [ms] (mean,across all concurrent requests)
Transfer rate: 1144.34[Kbytes/sec] received #平均每秒收到字节数
ConnectionTimes (ms)
min mean[+/-sd] median max
Connect: 3 473 286.7 625 2182
Processing: 99 3768 2052.3 3174 19915
Waiting: 0 1699 1663.2 780 7835
Total: 102 4241 2048.6 3486 20545
Percentageof the requests served within a certain time (ms)
50% 3486
66% 3997
75% 4633
80% 5281
90% 7159
95% 8564
98% 10118
99% 11416
100% 20545 (longest request)
ab测试举例二
[[email protected]/]# ab www.hao123.com/
Thisis ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensedto The Apache Software Foundation, http://www.apache.org/
Benchmarkingwww.hao123.com (be patient).....done
ServerSoftware: BWS/1.0
ServerHostname: www.hao123.com
Server Port: 80
DocumentPath: /
DocumentLength: 567641 bytes
ConcurrencyLevel: 1
Timetaken for tests: 0.948 seconds
Completerequests: 1
Failedrequests: 0
Writeerrors: 0
Totaltransferred: 568191 bytes
HTMLtransferred: 567641 bytes
Requestsper second: 1.05 [#/sec] (mean)
Timeper request: 948.005 [ms] (mean)
Timeper request: 948.005 [ms] (mean,across all concurrent requests)
Transferrate: 585.31 [Kbytes/sec]received
ConnectionTimes (ms)
min mean[+/-sd] median max
Connect: 64 64 0.0 64 64
Processing: 884 884 0.0 884 884
Waiting: 95 95 0.0 95 95
Total: 948 948 0.0 948 948