[Experience Sharing] Installing ab stress test tool and detailed explanation of ab command under linux

1 Introduction

ab (apache bench) is a performance testing tool for Apache Hypertext Transfer Protocol (HTTP). Its design intent is to describe the execution performance of the currently installed Apache, mainly to show how many requests per second your installed Apache can handle.
ab is very practical. It can not only perform website access stress test on apache server, but also perform stress test on other types of servers. Such as nginx, tomcat, IIS, etc.
When I learned about the ab tool, I was to compare the performance difference between direct python execution app and gunicorn under the flask framework.

2. Installation

yum -y install httpd-tools
ab -v 查看ab版本
ab --help

3. Use

ab -n 1000 -c 10 http://www.baidu.com/

-n access times, here is 1000 times,
-c concurrent number, here is 10
URLs must be followed by a / slash at the end, otherwise there will be an error
ab stress test return message content detailed explanation:

Server Software:        Apache  		#服务器软件
Server Hostname:        www.buruyouni.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)
1234567891011121314151617181920212223242526272829303132333435363738

4. Parameter explanation

(1) Throughput rate (Requests per second)
concept: A quantitative description of the concurrent processing capacity of a server, 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 for a certain number of concurrent users is called the maximum throughput rate.
Calculation formula: the total number of requests / the time it takes to process these requests, that is, Request per second = Complete requests / Time taken for tests
(2) The number of concurrent connections
concept: the number of concurrent connections accepted by the server at a certain moment The number of requests is simply a session.
(3) The number of concurrent users (Concurrency Level)
concept: pay attention to the difference between this concept and the number of concurrent connections. A user may have multiple sessions at the same time, that is, the number of connections.
(4) The average user request waiting time (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: the time taken to complete all the requests / the total number of requests, that is, Time taken for / testsComplete requests can be seen, it is the inverse of the throughput rate. At the same time, it also = average user request waiting time / number of concurrent users, that is, Time per request / Concurrency Levelab tool introduction

Guess you like

Origin blog.csdn.net/weixin_44704985/article/details/113972622