- ab的安装非常简单,如果是源码安装apache的话,那就更简单了。apache安装完毕后ab命令存放在apache安装目录的bin目录下。如下: /usr/local/apache2/bin
- 如果apache 是通过yum的RPM包方式安装的话,ab命令默认存放在/usr/bin目录下。如下:
- 可以通过 which ab 来查看是否安装了ab,以及ab的位置
- ab -V:检测是否安装ab以及版本信息
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
-t timelimit Seconds to max. to spend on benchmarking
This implies -n 50000
-s timeout Seconds to max. wait for each response
Default is 30 seconds
-b windowsize Size of TCP send/receive buffer, in bytes
-B address Address to bind to when making outgoing connections
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header to use for POST/PUT data, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234'. (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-q Do not show progress when doing more than 150 requests
-l Accept variable document length (use this for dynamic pages)
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don't exit on socket receive errors.
-m method Method name
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol
- 吞吐率(requests per second):描述服务器并发处理能力,单位是reqs/s,只的是在某个并发用户数下单位时间内能处理的请求数。吞吐率是基于用户并发数的。
- 并发连接数(he number of concurrent connections):指的是某个时刻服务器所接受的请求书目
- 并发用户数(Concurrency Level): 要注意区分这个概念和并发连接数之间的区别,一个用户可能同时会产生多个会话,也即连接数。在HTTP/1.1下,IE7支持两个并发连接,IE8支持6个并发连接,FireFox3支持4个并发连接,所以相应的,我们的并发用户数就得除以这个基数
- 用户平均请求等待时间(Time per request): 处理完成所有请求数所花费的时间/(总请求数/并发用户数)
- 服务器平均请求等待时间(Time per request:across all concurrent requests): 处理完成所有请求数所花费的时间/总请求数,即:Time taken for/testsComplete requests,可以看到,它是吞吐率的倒数。同时,它也等于用户平均请求等待时间/并发用户数,即Time per request/Concurrency Level
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.jd.com (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
Completed 1000 requests
Finished 1000 requests
Server Software: JDWS
Server Hostname: www.jd.com
Server Port: 80
Document Path: /error2.aspx
Document Length: 16503 bytes
Concurrency Level: 100
Time taken for tests: 13.908 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 16870000 bytes
HTML transferred: 16503000 bytes
Requests per second: 71.90 [#/sec] (mean)
Time per request: 1390.829 [ms] (mean)
Time per request: 13.908 [ms] (mean, across all concurrent requests)
min mean[+/-sd] median max
Connect: 7 127 282.3 47 1593
Processing: 27 697 1327.0 190 12730
Waiting: 11 167 374.4 57 3810
Total: 75 824 1425.5 287 12785
Percentage of the requests served within a certain time (ms)
50% 287
66% 586
75% 952
80% 1209
90% 1652
95% 2874
98% 5060
99% 8673
- Server Software:服务器软件,他这里用的JDWS(神马玩意)
- Server Hostname:主机名www.jd.com
- Server Port:端口80
- Document Path:请求文件的路径
- Document Length:响应文件的正文长度
- 下面关键了
- Concurrency Level:并发用户数,和设置的一样
- Time taken for tests: 任务处理完所花费的时间
- Complete requests: 总请求量
- Failed requests:失败的请求量
- Total transferred:示所有请求的响应数据长度总和,包括每个HTTP响应数据的头信息和正文数据的长度。注意这里不包括HTTP请求数据的长度,仅仅为web服务器流向用户PC的应用层数据总长度
- HTML transferred:表示所有请求的响应数据中正文数据的总和,也就是减去了Total transferred中HTTP响应数据中的头信息的长度。
- Requests per second : 吞吐率 计算公式:Complete requests/Time taken for tests
- Time per request:用户平均请求等待时间,计算公式:Time token for tests/(Complete requests/Concurrency Level)。
Time per requet(across all concurrent request):服务器平均请求等待时间,计算公式:Time taken for tests/Complete requests,正好是吞吐率的倒数。也可以这么统计:Time per request/Concurrency Level。 - Transfer rate:单位时间从服务器获取数据的长度,这个统计很好的说明服务器的处理能力达到极限时,其出口宽带的需求量
- Percentage of requests served within a certain time(ms):这部分数据用于描述每个请求处理时间的分布情况,