Super practical! Share a stress testing artifact: ab tool
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 testsThe 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 //平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题
- 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

According to benchmarks, Laravel excels in page loading speed and database queries, while CodeIgniter excels in data processing. When choosing a PHP framework, you should consider application size, traffic patterns, and development team skills.

Concurrent programming is implemented in Go through Goroutine and concurrency control tools (such as WaitGroup, Mutex), and third-party libraries (such as sync.Pool, sync.semaphore, queue) can be used to extend its functions. These libraries optimize concurrent operations such as task management, resource access restrictions, and code efficiency improvements. An example of using the queue library to process tasks shows the application of third-party libraries in actual concurrency scenarios.

Concurrency testing and debugging Concurrency testing and debugging in Java concurrent programming are crucial and the following techniques are available: Concurrency testing: Unit testing: Isolate and test a single concurrent task. Integration testing: testing the interaction between multiple concurrent tasks. Load testing: Evaluate an application's performance and scalability under heavy load. Concurrency Debugging: Breakpoints: Pause thread execution and inspect variables or execute code. Logging: Record thread events and status. Stack trace: Identify the source of the exception. Visualization tools: Monitor thread activity and resource usage.

There are a variety of attack methods that can take a website offline, and the more complex methods involve technical knowledge of databases and programming. A simpler method is called a "DenialOfService" (DOS) attack. The name of this attack method comes from its intention: to cause normal service requests from ordinary customers or website visitors to be denied. Generally speaking, there are two forms of DOS attacks: the third and fourth layers of the OSI model, that is, the network layer attack. The seventh layer of the OSI model, that is, the application layer attack. The first type of DOS attack - the network layer, occurs when a large number of of junk traffic flows to the web server. When spam traffic exceeds the network's ability to handle it, the website goes down. The second type of DOS attack is at the application layer and uses combined

To add a server to Eclipse, follow these steps: Create a server runtime environment Configure the server Create a server instance Select the server runtime environment Configure the server instance Start the server deployment project

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

To successfully deploy and maintain a PHP website, you need to perform the following steps: Select a web server (such as Apache or Nginx) Install PHP Create a database and connect PHP Upload code to the server Set up domain name and DNS Monitoring website maintenance steps include updating PHP and web servers, and backing up the website , monitor error logs and update content.

An important task for Linux administrators is to protect the server from illegal attacks or access. By default, Linux systems come with well-configured firewalls, such as iptables, Uncomplicated Firewall (UFW), ConfigServerSecurityFirewall (CSF), etc., which can prevent a variety of attacks. Any machine connected to the Internet is a potential target for malicious attacks. There is a tool called Fail2Ban that can be used to mitigate illegal access on the server. What is Fail2Ban? Fail2Ban[1] is an intrusion prevention software that protects servers from brute force attacks. It is written in Python programming language
