Apache Bench installation and use

1. Introduction to Apache Bench

ApacheBench is a web stress testing tool that comes with the Apache server, ab for short. ab is also a command-line tool, which has very low local requirements for initiating loads. According to the ab command, many concurrent access threads can be created to simulate multiple visitors accessing a URL address at the same time, so it can be used to test the target server. load pressure. In general, the ab tool is small and simple, quick to learn, and can provide the required basic performance indicators, but there is no graphical result and cannot be monitored.

 

2. Apache Bench installation

First, you need to install the Apache server, download address: https://www.apachelounge.com/download/ ,

It is recommended to download the latest version, because the old version of ab does not support the -r parameter.

 

Three, Apache Bench use

understand parameters

copy code
Parameter Description:
格式:ab [options] [http://]hostname[:port]/path

- n requests Number of requests to perform //Total number of requests initiated in this test-
 c concurrency Number of multiple requests to make //Number of requests (or concurrent) generated at one time
 -t timelimit Seconds to max. wait for responses / /Maximum number of seconds to run the test, no time limit by default.
-r Don't exit on socket receive errors. // Throw an exception to continue the test task
- p postfile File containing data to POST //The file containing the data that needs POST, the file format is "p1=1&p2=2". The usage method is -p 111.txt

-T content-type Content-type header for POSTing
 //Content-type header information used by POST data, such as -T "application/x-www-form-urlencoded". (with -p)
 -v verbosity How much troubleshooting info to print 
//Set the verbosity of the displayed information - 4 or more will display header information, 3 or more will display response codes (404, 200, etc.), 2 or greater to display warnings and other information. -V displays the version number and exits.
-C attribute Add cookie, eg. -C “c1=1234,c2=2,c3=3 ” (repeatable)
//-C cookie-name=value Append a Cookie: line to the request. Its typical form is a parameter pair name=value. This parameter can be repeated, separated by commas.
Tip: You can pass the JSESSIONID parameter with the help of the session implementation principle to achieve the function of maintaining the session, such as -C ” c1=1234,c2=2,c3=3, JSESSIONID= FF056CD16DA9D71CB131C1D56F0319F8″ . 
-w Print out results in HTML tables // Output results in HTML table format. By default, it is a table with a width of two columns on a white background. 
- i Use HEAD instead of GET
 - x attributes String to insert as table attributes
 - y attributes String to insert as tr attributes
 -z attributes String to insert as td or th attributes
 -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
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-h Display usage information (this message)
copy code

 

There are many parameters, generally we can use the -c and -n parameters. E.g:

# ab -c 10 -n 10 http://www.xiami.com/

Result parametric analysis:

copy code
Document Path: Test page
Document Length: page size
Concurrency Level: Concurrency of the test
Time taken for tests: the duration of the entire test
Complete requests: The number of completed requests
Failed requests: The number of failed requests
Write errors: 0
Total transferred: The amount of network transfers during the entire process
HTML transferred: The amount of HTML content transferred throughout the process
Requests per second: one of the most important indicators, equivalent to the number of transactions per second in LR, the mean in brackets behind it indicates that this is an average
Time per request: The second most important indicator, which is equivalent to the average transaction response time in LR. The mean in parentheses indicates that this is an average value.
Time per request: the average of the actual running time of each connection request
Transfer rate: The average traffic on the network per second, which can help to rule out whether there is a problem that the response time is prolonged due to excessive network traffic

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325392196&siteId=291194637