Installation and explanation of CentOS7 AB stress test
- Apache Benchmark (AB) is a self-contained stress testing tool in the Apache installation package. It is easy to use.
- Install and use AB in centOS7
- Note: I personally found that the previously installed centos6.5 has installed AB by default. The reason is unknown.
①. AB (apache benchmark) Installation
- Command:
yum -y install httpd-tools
②. AB test Command Parameters
- Command:
ab
Orab -help
- The following command parameters are displayed:
- AB [optional parameter options] url for stress testing
- Parameter description:
In addition, we will introduce the interface based on the above usage to learn more about the role of each parameter option. -N is requests, which is used to specify the total number of executions of a stress test. -C is concurrency, which is used to specify the number of concurrencies. -T is timelimit, and the maximum waiting time (unit: seconds ). -B is windowsize, And the buffer size for TCP sending/receiving (unit: bytes ). -P is postfile. The file to be uploaded when a POST request is sent must be set with the-T parameter. -U is the putfile. You must set the-T parameter to the file to be uploaded when sending a PUT request. -T is content-type. It is used to set Content-Type request header information, for example, application/x-www-form-urlencoded. The default value is text/plain. -V is verbosity, which specifies the redundancy level for printing help information. -W prints the result as an HTML table. -I use HEAD requests instead of GET requests. -X inserts a string as the attribute of the table label. -Y: inserts a string as the attribute of the tr tag. -Z inserts a string as the property of the td tag. -C: Add cookie information, for example, "Apache = 1234" (you can repeat this parameter option to add multiple ). -H: add any request header, for example, "Accept-Encoding: gzip ", the request header is added after multiple existing request headers (you can repeat this option to add multiple ). -A adds A basic network authentication information, which is separated by A colon. -P adds a basic proxy authentication information, which is separated by a colon. -X indicates the used and port number, for example, "126.10.10.3: 88 ". -V: print the version number and exit. -K uses the KeepAlive feature of HTTP. -D: The percentage is not displayed. -S does not display estimation and warning information. -G outputs the result information to the gnuplot format file. -E outputs the result information to a CSV file. -R indicates that the program will not exit when an error message is received. -H indicates the usage information, which is actually AB-help.
③ Use of AB
- Simulate 100 concurrent requests, with a total of 10000 requests
- Command template:
AB-c 100-n 10000 website to be tested (full path recommended)
- Description:
Server Software: nginx/1.10.2 (Server Software name and version information) Server Hostname: 192.168.1.106 (Server host name) Server Port: 80 (Server Port) Document Path:/index1.html. (URL path for testing) Document Length: 3721 bytes (Document size returned by the URL for testing) Concurrency Level: 1000 (Concurrency) Time taken for tests: 2.327 seconds (total time consumed by stress testing) Complete requests: 5000 (total times) Failed requests: 688 (number of Failed requests) Write errors: 0 (number of network connection Write errors) total transferred: 17402975 bytes (Total data volume transmitted) HTML transferred: 16275725 bytes (Total data volume of HTML documents) Requests per second: 2148.98 [#/sec] (mean) (average number of requests per second) This is a very important parameter value, server throughput Time per request: 465.338 [MS] (mean) (all concurrent users (here 1000) average Time of all requests) Time request: 0.247 [MS] (mean, average SS all concurrent requests) (average Time of one user request) Transfer rate: 7304.41 [Kbytes/sec] the length of the data obtained by the received per second (transmission rate, unit: KB/s )... percentage of the requests served within a certain time (MS) 50% 347 # 50% requests returned within milliseconds 66% 401 # 60% requests returned within 75% 431 80% 516 90% 600 95% 846 98% 1571 99% 1593 100% 1619 (longest request)
④. 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
- A simple explanation: the server with too many concurrent access requests rejects access. Theoretically, the system configuration can provide better affordability.
⑤. Precautions
- Test Machines and tested machines should be separated
- Do not perform stress tests on online servers
- Observe that the machine where the test tool AB is located and the CPU, memory, and network of the tested front-end machine cannot exceed 75% of the maximum.
6. Recommended articles
- Use AB for page stress testing (refer to the description)
- Detailed description of the use of apache Performance Testing Tool AB