日期:2014-05-17  浏览次数:20830 次

【转】apache压测命令ab

ab的全称是ApacheBench,是Apache附带的一个小工具,专门用于HTTP Server的benchmark testing,可以同时模拟多个并发请求。

?

在这个例子的一开始,我执行了这样一个命令ab -n 10 -c 10 http://www.google.com/?。这个命令的意思是启动ab,

向www.google.com发送10个请求(-n 10) ,并每次发送10个请求(-c 10)?——也就是说一次都发过去了。跟着下面的是ab输出的测试报告,红色部分是我添加的注释。*



D:\apahce\bin>ab.exe -n 10 -c 10 http://www.google.com/
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 www.google.com (be patient).....done


Server Software:????????gws
Server Hostname:????????www.google.com
Server Port:????????????80

Document Path:??????????/
Document Length:????????4941 bytes

Concurrency Level:??????10
Time taken for tests:???5.218750 seconds//**整个测试持续的时间**
Complete requests:??????10//**完成的请求数量**
Failed requests:????????9//**失败的请求数量**
???(Connect: 0, Length: 9, Exceptions: 0)
Write errors:???????????0
Total transferred:??????52730 bytes**整个场景中的网络传输量**
HTML transferred:???????49540 bytes**整个场景中的HTML内容传输量**
Requests per second:????1.92 [#/sec] (mean) **大家最关心的指标之一,相当于LR中的每秒事务数,后面括号中的mean表示这是一个平均值**?
Time per request:???????5218.750 [ms] (mean) *大家最关心的指标之二,相当于LR中的平均事务响应时间,后面括号中的mean表示这是一个平均值**?
Time per request:???????521.875 [ms] (mean, across all concurrent requests)
Transfer rate:??????????9.77 [Kbytes/sec] received*平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题**?

Connection Times?(ms)?
??????????????min??mean[+/-sd] median???max
Connect:??????187??488 257.6????437?????921
Processing:???312?1673?1204.4???1547????3985?
Waiting:??????296 1668 1206.3???1546????3984
Total:????????593 2162 1432.6???1890????4906
**下面的内容为整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50%的用户响应时间小于**毫秒,60%的用户响应时间小于**毫秒,最大的响应时间小于??**毫秒**
Percentage of the requests served within a certain time?(ms)?
??50%???1890
??66%???2406
??75%???3093
??80%???3984?
??90%???4906
??95%???4906
??98%???4906
??99%???4906
?100%???4906 (longest request)





格式: ./ab [options] [http://]hostname[:port]/path
参数:
????-n requests?????Number of requests to perform
????//在测试会话中所执行的请求个数。默认时,仅执行一个请求
?.?相当于用户数?
????-c concurrency Number of multiple requests to make
????//一次产生的请求个数?。默认是一次一个。?

????-t timelimit????Seconds to max. wait for responses
????//测试所进行的最大秒数?。
?其内部隐含值是-n 50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
????-p postfile?????File containing data to POST
????//包含了需要POST的数据的文件.?
????-T content-type Co