标签:
原文:http://blog.linuxeye.com/124.html
Apache附带的ab,它非常容易使用,ab可以直接在Web服务器本地发起测试请求。这至关重要,因为我们希望测试的服务器的处理时间,而不包含数据的网络传输时间以及用户PC本地的计算时间。
需要清楚的是,ab进行一切测试的本质都是基于HTTP,所以可以说它是对于Web服务器软件的黑盒性能测试,它获得的一切数据和计算结果,都可以通过HTTP来解释。
另有一些压力测试软件,包括LoadRnner、Jmeter等,则是不同程度上包含了服务器处理之外的时间,比如LoadRunner运行在用户PC上,可以录制浏览器行为,这种测试的结果玩玩侧重于站点用户的角度,有另外一些层面的参考意义。
接下来,将使用ab来进行一次压力测试,在本书中我们使用Apache 2.3中附带的ab,其版本信息如下所示:
[root@localhost ~]#/usr/local/apache/bin/ab -VThis is ApacheBench,Version2.3<$Revision:655654 $>Copyright1996AdamTwiss,ZeusTechnologyLtd, http://www.zeustech.net/Licensed to TheApacheSoftwareFoundation, http://www.apache.org/
请看下面的命令行信息:
[root@localhost ~]# /usr/local/apache/bin/ab -n1000 -c10 http://localhost/index.htmlThis is ApacheBench,Version2.3<$Revision:655654 $>Copyright1996AdamTwiss,ZeusTechnologyLtd, http://www.zeustech.net/Licensed to TheApacheSoftwareFoundation, http://www.apache.org/Benchmarking localhost (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.19ServerHostname: localhost
ServerPort:80DocumentPath:/index.html
DocumentLength:45 bytes
ConcurrencyLevel:10Time taken for tests:0.454 seconds
Complete requests:1000Failed requests:0Write errors:0Total transferred:322644 bytes
HTML transferred:45090 bytes
Requests per second:2204.64[#/sec] (mean)Time per request:4.536[ms](mean)Time per request:0.454[ms](mean, across all concurrent requests)Transfer rate:694.64[Kbytes/sec] received
ConnectionTimes(ms)
min mean[+/-sd] median max
Connect:010.515Processing:135.6262Waiting:035.6262Total:145.6363Percentage of the requests served within a certain time (ms)50%366%475%480%490%695%1298%2699%