ab pressure test command

command install

yum -y install httpd-tools

example

There are many command parameters of ab, the -c and -n parameters are often used, and the URL must be followed by a / slash at the end

ab -n1000 -c 10 http://www.wmmzz.com/

-n visits 1000 times, -c concurrently 10

Server Software:        Apache  		#服务器软件
Server Hostname:        www.wmmzz.com   #域名
Server Port:            80 				#请求端口号

Document Path:          /   			#文件路径
Document Length:        40888 bytes 	#页面字节数

Concurrency Level:      10   			#请求的并发数
Time taken for tests:   27.300 seconds  #总访问时间
Complete requests:      1000   			#请求成功数量
Failed requests:        0      			#请求失败数量
Write errors:           0
Total transferred:      41054242 bytes  #请求总数据大小(包括header头信息)
HTML transferred:       40888000 bytes  #html页面实际总字节数
Requests per second:    36.63 [#/sec] (mean)  #每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量
Time per request:       272.998 [ms] (mean)     #用户平均请求等待时间 
Time per request:       27.300 [ms] (mean, across all concurrent requests)
												# 服务器平均处理时间,也就是服务器吞吐量的倒数 
Transfer rate:          1468.58 [Kbytes/sec] received  #每秒获取的数据长度

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       43   47   2.4     47      53
Processing:   189  224  40.7    215     895
Waiting:      102  128  38.6    118     794
Total:        233  270  41.3    263     945

Percentage of the requests served within a certain time (ms)
  50%    263    #50%用户请求在263ms内返回
  66%    271    #66%用户请求在271ms内返回
  75%    279    #75%用户请求在279ms内返回
  80%    285    #80%用户请求在285ms内返回
  90%    303    #90%用户请求在303ms内返回
  95%    320    #95%用户请求在320ms内返回
  98%    341    #98%用户请求在341ms内返回
  99%    373    #99%用户请求在373ms内返回
 100%    945 (longest request)

Parameter Description

-n在测试会话中所执行的请求个数。默认时,仅执行一个请求。

-c一次产生的请求个数。默认是一次一个。

-t测试所进行的最大秒数。其内部隐含值是-n 50000,它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。

-p包含了需要POST的数据的文件。

-P对一个中转代理提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送。

-T POST数据所使用的Content-type头信息。

-v设置显示信息的详细程度-4或更大值会显示头信息,3或更大值可以显示响应代码(404,200等),2或更大值可以显示警告和其他信息。

-V显示版本号并退出。

-w以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。

-i执行HEAD请求,而不是GET。

-x设置<table>属性的字符串。

-X对请求使用代理服务器。

-y设置<tr>属性的字符串。

-z设置<td>属性的字符串。

-C对请求附加一个Cookie:行。其典型形式是name=value的一个参数对,此参数可以重复。

-H对请求附加额外的头信息。此参数的典型形式是一个有效的头信息行,其中包含了以冒号分隔的字段和值的对(如,"Accept-Encoding:zip/zop;8bit")。

-A对服务器提供BASIC认证信任。用户名和密码由一个:隔开,并以base64编码形式发送。无论服务器是否需要(即,是否发送了401认证需求代码),此字符串都会被发送。

-h显示使用方法。

-d不显示"percentage served within XX [ms] table"的消息(为以前的版本提供支持)。

-e产生一个以逗号分隔的(CSV)文件,其中包含了处理每个相应百分比的请求所需要(从1%到100%)的相应百分比的(以微妙为单位)时间。由于这种格式已经“二进制化”,所以比'gnuplot'格式更有用。

-g把所有测试结果写入一个'gnuplot'或者TSV(以Tab分隔的)文件。此文件可以方便地导入到Gnuplot,IDL,Mathematica,Igor甚至Excel中。其中的第一行为标题。

-i执行HEAD请求,而不是GET。

-k启用HTTP KeepAlive功能,即在一个HTTP会话中执行多个请求。默认时,不启用KeepAlive功能。

-q如果处理的请求数大于150,ab每处理大约10%或者100个请求时,会在stderr输出一个进度计数。此-q标记可以抑制这些信息。

Performance

Several indicators are more important in the process of performance testing:

1. Throughput rate (Requests per second)

The quantitative description of the server's concurrent processing capability, the unit is reqs/s, which refers to the number of requests processed per unit time under a certain number of concurrent users. The maximum number of requests that can be processed per unit time under a certain number of concurrent users is called the maximum throughput rate.

Remember: Throughput is based on the number of concurrent users. This sentence represents two meanings:

a. The throughput rate is related to the number of concurrent users

b. With different numbers of concurrent users, the throughput rate is generally different

Calculation formula: total number of requests/time it takes to process and complete these requests, ie

Request per second=Complete requests/Time taken for tests

It must be noted that this value represents the overall performance of the current machine, and the larger the value, the better.

2. The number of concurrent connections

The number of concurrent connections refers to the number of requests accepted by the server at a certain moment. Simply put, it is a session.

3. Number of concurrent users (Concurrency Level)

Pay attention to the difference between this concept and the number of concurrent connections. A user may generate multiple sessions at the same time, that is, the number of connections. Under HTTP/1.1, IE7 supports two concurrent connections, IE8 supports six concurrent connections, and FireFox3 supports four concurrent connections, so correspondingly, our number of concurrent users has to be divided by this base.

4. Average request waiting time of users (Time per request)

Calculation formula: the time it takes to process all requests/(total requests/concurrent users), that is:

Time per request=Time taken for tests/(Complete requests/Concurrency Level)

5. Server average request waiting time (Time per request: across all concurrent requests)

Calculation formula: time spent processing all requests/total number of requests, namely:

Time taken for/testsComplete requests

可以看到,它是吞吐率的倒数。

同时,它也等于用户平均请求等待时间/并发用户数,即 Time per request/Concurrency Level

参考文献:

https://blog.csdn.net/qq_27517377/article/details/78794409

https://www.cnblogs.com/dragonflyer/p/6137514.html

Guess you like

Origin blog.csdn.net/OfficerGoodbody/article/details/126662456