Analysis on the use of apache stress testing tool AB

Source: Internet
Author: User
Tags response code port number server port

AB is a very easy-to-use stress testing tool. It does not need to be installed in linux. Here are several key parameters of AB and examples of use.
Requests per second: the number of Requests per second. This is an important parameter value, indicating the server throughput.
Time per request: average user request wait Time
Time per request: average server processing Time, that is, the reciprocal of server throughput
Transfer rate: the length of data obtained per second.

For example, Baidu's stress testing has 50 concurrent requests for 1000 requests

AB-n 1000-c 50 http://www.111cn.net/

The result is as follows:

[Root @ JOE-PC ~] # AB-n 1000-c 50 http://www.111cn.net/
This is apacheloud, Version 2.3 & lt; $ Revision: 655654 $ & gt;

 
Benchmarking www.111cn.net (be patient)
Completed100 requests
Completed200 requests
Completed300 requests
Completed400 requests
Completed500 requests
Completed600 requests
Completed700 requests
Completed800 requests
Completed900 requests
Completed1000 requests
Finished 1000 requests
 
Server Software: BWS/1.0
Server Hostname: www.111cn.net
Server Port: 80
 
Document Path :/
Document Length: 10969 bytes
 
Concurrency Level: 50
Time taken for tests: 12.321 seconds
Complete requests: 1000
Failed requests: 452
(Connect: 0, Receive: 0, Length: 452, Exceptions: 0)
Write errors: 0
Total transferred: 11343952 bytes
HTML transferred: 10794566 bytes
Requests per secondd: 81.16 [#/sec] (mean)
Time per request: 616.039 [MS] (mean)
Time per request: 12.321 [MS] (mean, internal SS all concurrent requests)
Transfer rate: 899.14 [Kbytes/sec] canceled ed
 
Connection Times (MS)
Min mean [+/-sd] median max
Connect: 6 174 341.0 87 3085
Processing: 6 363 516.3 207 5062
Waiting: 4 153 135.3 106 1502
Total: 23 536 611.3 295 5152
 
Percentage of the requests served within a certain time (MS)
50% 295
66% 396
75% 661
80% 771
90% 1282
95% 1569
98% 2499
99% 3535
100% 5152 (longest request)

ApacheBench parameter description

Format: AB [options] [http: //] hostname [: port]/path
Parameter description:
-N requests Number of requests to perform
// The number of requests executed in the test session (total number of page accesses in this test ). By default, only one request is executed.
-C concurrency Number of multiple requests to make
// Number of requests generated at a time (number of concurrent requests ). The default value is one at a time.
-T timelimit Seconds to max. wait for responses
// The maximum number of seconds for testing. The implicit value is-n 50000. It limits the server test to a fixed total time. By default, there is no time limit.
-P postfile File containing data to POST
// The file that contains the data to be POST. The format of the file is "p1 = 1 & p2 = 2". The usage is-p 111.txt. (Cooperation-T)
-T content-type Content-type header for POSTing
// The Content-type header used by the POST data, such as-T "application/x-www-form-urlencoded ". (With-p)
-V verbosity How much troubleshooting info to print
// Set the details of the display information-4 or a greater value will display the header information, 3 or a greater value can display the response code (404,200, etc ), 2 or a greater value can display warnings and other information. -V displays the version number and exits.
-W Print out results in HTML tables
// Output results in HTML table format. By default, it is a table of the width of the two columns of the white background.
-I Use HEAD instead of GET
// Execute the HEAD request 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
-C attribute Add cookie, eg.-C "c1 = 1234, c2 = 2, c3 = 3 & Prime; (repeatable)
//-C cookie-name = value attaches a Cookie to the request: Row. The typical form is a parameter pair of name = value. This parameter can be repeated and separated by commas.
Tip: you can use the session implementation principle to pass the JSESSIONID parameter to achieve session persistence, as shown in figure
-C "c1 = 1234, c2 = 2, c3 = 3, JSESSIONID = ff056cd16da9d71cb1_c1d56f0319f8 & Prime ;.
-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.
//-P proxy-auth-username: password provides BASIC authentication trust for a transit proxy. The user name and password are separated by one and sent in base64 encoding format. This string is sent regardless of whether the server needs it (that is, whether the 401 authentication request code is sent.
-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)
//-Attributes: specifies the attribute string. The defect program contains various static declared fixed-length buffers. In addition, parsing command line parameters, server response headers, and other external inputs is also simple, which may have adverse consequences. It does not fully implement HTTP/1.x; only accept some 'preview' response formats. Frequent use of strstr (3) may cause performance problems, that is, you may be testing the performance of AB rather than the server.

There are many parameters. Generally we can use the-c and-n parameters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.