Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ab stress testing tool

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly analyzes the relevant knowledge points of how to use the ab stress testing tool, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor and learn more about "how to use ab stress testing tools".

Background

Apache Benchmark (ab for short) is a stress testing tool included in the Apache installation package, which is easy to use.

The installation and use of ab under centOS7 are provided here.

Note: I found that ab has been installed by default in the previously installed centos6.5, but the specific reason is unknown.

① .ab (apache benchmark) installation

Command: yum-y install httpd-tools

Command parameters for ② .ab test

Command: ab or ab-help

The display command parameters are as follows

Ab [optional parameter options] url that requires stress testing

Parameter description:

In addition, we will learn more about the role of each parameter option according to the usage introduction interface above.

-n is requests, which is used to specify the total number of times the stress test is performed.

-c is concurrency for the specified number of concurrency.

-t is the timelimit, the maximum time to wait for a response (in seconds).

-b is the buffer size (in bytes) sent / received by windowsize,TCP.

-p is postfile, the file that needs to be uploaded when sending a POST request. In addition, the-T parameter must be set.

-u is putfile, the file that needs to be uploaded when sending a PUT request. In addition, the-T parameter must be set.

-T is content-type, which is used to set the Content-Type request header information, such as application/x-www-form-urlencoded. The default value is text/plain.

-v, or verbosity, specifies the level of redundancy at which help information is printed.

-w print the results in the form of a HTML table.

-I use HEAD requests instead of GET requests.

-x inserts a string as an attribute of the table tag.

-y inserts a string as an attribute of the tr tag.

-z inserts a string as an attribute of the td tag.

-C add cookie information, such as "Apache=1234" (you can repeat this parameter option to add multiple).

-H add any request headers, such as "Accept-Encoding: gzip". The request headers will be added after the existing multiple request headers (you can repeat this parameter option to add multiple).

-An adds a basic network authentication information, separated by an English colon between the user name and password.

-P add a basic proxy authentication information, separated by an English colon between the user name and password.

-X specifies the and port number to use, for example: "126.10.10.3 rig 88".

-V prints the version number and exits.

-k uses the KeepAlive feature of HTTP.

-d does not display percentages.

-S does not display estimates and warnings.

-g output the result information to a file in gnuplot format.

-e outputs the result information to a file in CSV format.

-r specifies that the program does not exit when an error message is received.

-h shows usage information, which is actually ab-help.

The use of ③ .ab

Simulate 100 concurrent requests for a total of 10000 requests

Command template:

Ab-c 100-n 10000 website to be tested (full path recommended)

Server Software: nginx/1.10.2 (server software name and version information) Server Hostname: 192.168.1.106 (server hostname) Server Port: 80 (server port) Document Path: / index1.html. (URL path for testing) Document Length: 3721 bytes (size of documents returned by URL for testing) Concurrency Level: 1000 (concurrency) Time taken for tests: 2.327 seconds (total time consumed by stress tests) Complete requests: 5000 (total number of failed requests) Write errors: 0 (number of network connection write errors) Total transferred: 17402975 bytes (total data transferred) HTML transferred: 16275725 bytes (total HTML documents) Data volume) Requests per second: 2148.98 [# / sec] (mean) (average requests per second) this is a very important parameter value Server throughput Time per request: 465.338 [ms] (mean) (average time for all concurrent users (here 1000) to make a request) Time request: 0.247 [ms] (mean, across all concurrent requests) (average time for a single user to request) Transfer rate: 7304.41 [Kbytes/sec] received length of data obtained per second (transfer rate, unit: KB/s). Percentage of the requests served within a certain time (ms) 50% 347 # # 50% requests return 66% 401 # # 60% requests in 401ms 75% 431% 80% 516 90% 600 95% 846 98% 1571 99% 1593 1619 (longest request)

4. Stress test (example)

[test 1]:

Command ab-c 100-n 5000 http://192.168.1.106/index1.html

[test 2]:

Command ab-c 10000-n 50000 http://192.168.1.106/index1.html

Simple explanation: if the concurrent access volume is too large, the server refuses to access, in theory, through the system configuration, it can have a better bearing capacity.

5. Matters needing attention

The test machine should be separated from the machine to be tested.

Don't do stress tests on online servers.

Observe that the machine where the test tool ab is located, and the CPU, memory, network, etc. of the front-end machine under test are no more than 75% of the maximum.

This is the end of the introduction on "how to use the ab stress testing tool". More related content can be searched for previous articles, hoping to help you answer questions and questions, please support the website!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report