1. Brief description of the pressure test tool AB (Apachebench)
1) website Performance Stress testing is an essential part of the performance tuning process. It is only when the server is under high pressure that it can truly reflect the problems exposed by the various settings. Apache has a self-contained program called AB that can be used for Web site stress testing on Apache or other types of servers.
2) apachebench command principle:
The AB command creates many concurrent access threads, simulating multiple visitors accessing a URL address at the same time. Its test target is URL-based, so it can be used to test the load pressure of Apache, as well as other Web servers such as Nginx, Lighthttp, Tomcat, and IIS.
The AB command is very low on the computer that emits the load, does not occupy a high CPU, and does not consume a lot of memory, but it can cause a huge load on the target server, which is similar to the CC attack. The use of their own testing should also be noted, or too much load at a time, may cause the target server due to resource consumption, serious even caused the crash.
2.ApacheBench parameter Description
1Format: AB [options] [http://]hostname[:p ort]/Path2 parameter Description:3-N Requests number of requests to perform4//The number of requests executed in the test session (the total number of times the page was visited for this test). By default, only one request is executed. 5-c concurrency number of multiple requests to make6//the number of requests produced at one time (number of concurrent). The default is one at a time. 7-T timelimit Seconds to max. Wait for responses8The maximum number of seconds the test takes. Its internal implied value is-n50000. It allows you to limit the testing of the server to a fixed total time. By default, there is no time limit. 9-p postfile File containing data to POSTTenA file that contains the data that needs to be post, such as the file format "p1=1&p2=2". Using the method is-p111txt WithT) One-T Content-type content-Type header for POSTing AThe Content-type header information used by the post data, such as-T "application/x-www-form-urlencoded". Withp) --v verbosity how much troubleshooting info to print -Set the verbosity of display information –4 or greater displays the header information, 3 or greater to display the response code (404, 200, etc.), 2 or greater can display warnings and other information. -V Displays the version number and exits. the-W Print out results in HTML tables -//outputs the result in the format of an HTML table. By default, it is a table with a two-column width on a white background. --I use HEAD instead ofGET -//executes the head request instead of get. +-X AttributesStringTo Insert as table attributes --Y attributesStringTo Insert as TR attributes +-Z AttributesStringTo insert as TDorth attributes A-C attribute Add cookie, eg. -C "c1=1234, c2=2, c3=3″ (repeatable) at-C Cookie-name=value attach a cookie to the request: line. The typical form is name=A parameter pair of value. This parameter can be repeated, separated by commas. - Tip: You can use the session implementation principle to pass Jsessionid parameters, to achieve the function of maintaining the session, such as --C "c1=1234, c2=2, c3=3, jsessionid=Ff056cd16da9d71cb131c1d56f0319f8″. --H attribute Add arbitrary header line, eg. ' Accept-Encoding:gzip ' Inserted after all normal header lines. (repeatable) --A attribute Add Basic WWW authentication, the attributes -is a colon separated username andpassword. in-P attribute Add Basic Proxy authentication, the attributes -is a colon separated username andpassword. to-P proxy-auth-Username:password provides a Basic authentication trust to a transit agent. The user name and password are separated by a: and sent in Base64 encoded form. This string is sent regardless of whether the server is required (that is, if the 401 authentication requirement code is sent). +-X Proxy:portproxyserver andPort number to use --V Print version number and Exit the-k use HTTP KeepAlive feature *-D Do notshow percentiles served table. $-S Do notShow Confidence estimators andwarnings.Panax Notoginseng-g filename Output collected data to gnuplot format file. --e filename Output CSV file with percentages served the-h Display Usage information (this message) +-attributes the string that sets the property. There are various statically declared fixed-length buffers in the defect program. In addition, parsing of command-line arguments, the response headers of the server, and other external inputs can be very simple, which may have undesirable consequences. It does not completely implement http/1. x; Accept only certain ' expected ' response formats. Strstr3The frequent use of this may result in performance problems, i.e. you may be testing the performance of AB rather than the server.
3.ApacheBench usage:
1) in Linux system, the general installation of Apache can be directly executed:
such as: Ab–n 4000–c http://www.baidu.com/
A test that represents a total of 4000 requests for http://www.baidu.com, one request of 1000
2) in Window System, the Apache software can be used to open the CMD Command Line window, CD to the Apache installation directory of the bin directory;
such as: Ab-n 1000-c Http://123.56.153.48/beijing/Case?number=5&token
Its execution is shown in the following diagram:
Results Analysis:
This is apachebench, Version 2.3 < $Revision: 1638069 $>
Copyright 1996 Adam Twiss, Zeus technology LTD, http://www.zeustech.net/
Licensed to the Apache software Foundation, http://www.apache.org/
Benchmarking 123.56.153.48 (Be patient)
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Finished requests
Server software:nginx/1.6.2
Server hostname:123.56.153.48
Server port:80
Test page:
Document Path:/beijing/case?number=5
Size of page:
Document length:3693 bytes
Number of requests at one time
Concurrency level:100
Duration of the entire test:
Time taken for tests:70.662 seconds
Number of requests completed:
Complete requests:1000
Number of failed requests
Failed requests:0
Non-2xx responses:1000
The amount of network traffic throughout the process:
Total transferred:3881000 bytes
The amount of HTML content transferred throughout the process
HTML transferred:3693000 bytes
One of the most important indicators, equivalent to the number of transactions per second in LR, can be understood as the actual number of requests per second (mean means that this is an average)
Requests per second:14.15 [#/sec] (mean)
The two most important indicators are equivalent to the average transaction response time in LR (mean means that this is an average)
Time per request:7066.204 [MS] (mean)
Average of actual elapsed time for each connection request
Time per request:70.662 [MS] (mean, across all concurrent requests)
Average traffic on the network per second can help eliminate the problem of extended response times due to excessive network traffic
Transfer rate:53.64 [Kbytes/sec] Received
Decomposition of time consumed on the network:
Connection Times (MS)
Min MEAN[+/-SD] Median max
CONNECT:59 70 5.8 70 126
processing:70 6645 1245.8 6977 7291
waiting:67 3505 2028.6 3515 7229
total:135 6715 1246.1 7047 7360
The response of the request in the entire scenario is a response time for each request in the scene, where 50% of the user's response time is less than 7047 milliseconds and the maximum response time is less than 7343 milliseconds.
In the case of concurrent requests, the CPU is not actually processed at the same time, but is rotated on a per-request basis, so the basic first time of the request is approximately equal to the second time per request multiplied by the number of concurrent requests.
Percentage of the requests served within a certain time (MS)
50% 7047
66% 7075
75% 7085
80% 7094
90% 7231
95% 7315
98% 7339
99% 7343
100% 7360 (Longest request)
Summary: In the remote Web server stress testing, often the effect is not ideal (because the network delay too large), it is recommended to use the intranet of another or more servers through the intranet to test, so that the data obtained, the accuracy will be much higher. If you only have a single server, you can test it directly locally, which is more accurate than the remote test effect.
Operating instructions for the Apache Medium pressure test Tool AB