日期:2014-05-16  浏览次数:20870 次

Apache自带的性能测试工具ab的使用

刚开始的时候,对于压力测试感觉就是空白一片,后来查了查资料感觉其实一旦入门,一切不会是想象中那么难。

????进入cmd命令行模式,把目录切换到apache下的ab.exe所在的路径,我装的是集成的appserv,所以路径是:D:\AppServ\Apache2.2\bin,这个都是次要的,只要有Apache的ab.exe就能够进行压力测试。

???然后在这个下面键入:ab -n 1000 -c 50?http://localhost/site/index.php

???然后就会返回结果了:

D:\AppServ\Apache2.2\bin>ab -n 1000 -c 50?http://localhost/site/test.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd,?http://www.zeustech.net/
Copyright 2006 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
Finished 1000 requests


Server Software:????????Apache/2.2.8
Server Hostname:????????localhost
Server Port:????????????80

Document Path:??????????/site/test.php??//请求的资源
Document Length:????????26 bytes??// 文档返回的长度,不包括相应头

Concurrency Level:??????50????// 并发个数
Time taken for tests:???12.485334 seconds??//请求消耗的总时间
Complete requests:??????1000??//总请求数
Failed requests:????????0
Write errors:???????????0
Total transferred:??????219000 bytes
HTML transferred:???????26000 bytes
Requests per second:????80.09 [#/sec] (mean)??// 平均每秒的请求数
Time per request:???????624.267 [ms] (mean)???// 平均每个请求消耗的时间
Ti