Super practical! Share a stress testing artifact: ab tool

青灯夜游
Release: 2022-05-12 14:54:49
forward
3076 people have browsed it

Software stress testing is a basic quality assurance behavior that is part of every important software testing work. Therefore, stress testing is very important, so how to conduct stress testing? In this article, I will share with you a super practical stress testing tool - ab tool (apache bench). I hope it will be helpful to you!

Recommended related video tutorials: "tens of millions of data concurrency solutions (theoretical practice)"

Written in Previously


Before learning the ab tool, we need to understand several concepts about stress testing

  • Throughput rate (Requests per second)
    Concept: A 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 for 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.
    Calculation formula: total number of requests / time taken to process these requests, that is,
    Request per second = Complete requests / Time taken for tests

  • The number of concurrent connections
    Concept: The number of requests accepted by the server at a certain time, simply speaking, is a session.

  • 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.

  • User average request waiting time (Time per request)
    Calculation formula: time spent processing all requests / (total number of requests / concurrent Number of users), i.e.
    Time per request = Time taken for tests / ( Complete requests / Concurrency Level)

  • Server average request waiting time (Time per request: across all concurrent requests)
    Calculation formula: The time it takes to complete all requests/the total number of requests, that is,
    Time taken for / testsComplete requests
    As you can see, it is the reciprocal 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 Level

Ab tool introduction


ab’s full name is: apache bench

  • The explanation on the official website is as follows:

ab is a performance testing tool for Apache Hypertext Transfer Protocol (HTTP). Its design intention is to depict the execution performance of the currently installed Apache, mainly to show how many requests per second your installed Apache can handle.

  • Explanation from other websites:

ab is apache’s own stress testing tool. ab is very practical. It can not only perform website access stress testing on the apache server, but also perform stress testing on other types of servers. Such as nginx, tomcat, IIS, etc.

Download ab tool


Go to the apache official website http://httpd.apache.org/ and download apache

Start the ab tool


Take the apache installation path as C:\apache\Apache24\ in the windows environment as an example

Open the terminal and enter the command
cd C:\apache\Apache24\bin
to start ab

Start testing


Enter the command
ab -n 100 -c 10 http://test.com/
where -n represents the number of requests, - c represents the number of concurrencies

For other commands, please refer to http://apache.jz123.cn/programs/ab.html

Test result analysis


After the above command is run, the test report will come out


Complete test report

  • This paragraph shows the web From the server information, you can see that the server uses nginx, the domain name is wan.bigertech.com, and the port is 80


Server information

  • This paragraph is related information about the requested document. The location is "/" and the size of the document is 338436 bytes (this is the body length of the http response)


Document information

  • This section shows severalimportant indicators of stress testing


Important indicators

Concurrency Level: 100 //并发请求数 Time taken for tests: 50.872 seconds //整个测试持续的时间 Complete requests: 1000 //完成的请求数 Failed requests: 0 //失败的请求数 Total transferred: 13701482 bytes //整个场景中的网络传输量 HTML transferred: 13197000 bytes //整个场景中的HTML内容传输量 Requests per second: 19.66 [#/sec] (mean) //吞吐率,大家最关心的指标之一,相当于 LR 中的每秒事务数,后面括号中的 mean 表示这是一个平均值 Time per request: 5087.180 [ms] (mean) //用户平均请求等待时间,大家最关心的指标之二,相当于 LR 中的平均事务响应时间,后面括号中的 mean 表示这是一个平均值 Time per request: 50.872 [ms] (mean, across all concurrent requests) //服务器平均请求处理时间,大家最关心的指标之三 Transfer rate: 263.02 [Kbytes/sec] received //平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
Copy after login
  • This paragraph represents the breakdown of time spent on the network


Network consumption time

  • This section is the distribution of each request processing time. 50% of the processing time is within 4930ms, 66% of the processing time is within 5008ms..., the important thing is to see90%processing time.


Response

Questions about login


Sometimes stress testing requires users to log in, what should I do?
Please refer to the following steps:

  • After logging in with your account and password, use the developer tools to find the cookie value (Session ID) that identifies this session and write it down

  • If only one Cookie is used, then just type the command:
    ab -n 100 -C key=value http://test.com/

    If you need multiple cookies, just set the Header directly:
    ab -n 100 -H "Cookie: Key1=Value1; Key2=Value2" http://test.com/

Summary


# Generally speaking, the ab tool ab is small and simple, you can get started and learn quickly, and it can provide the needed Basic performance indicators, but there are no graphical results and cannot be monitored. Therefore the ab tool can be used for temporary emergency tasks and simple testing.

Same type of stress testing tools include: webbench, siege, http_load, etc.

Recommended learning:nginx tutorial

The above is the detailed content of Super practical! Share a stress testing artifact: ab tool. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!