Detailed explanation of the AB (Apache protocol) command and stress test simulation, apachebench

Source: Internet
Author: User
Tags cipher suite

Detailed explanation of the AB (Apache protocol) command and stress test simulation, apachebench

Introduction

Apache is a web stress testing tool (AB) that comes with the Apache server. AB is also a command line tool that has very low requirements on the local machine that initiates the load. According to the AB command, many concurrent access threads can be created to simulate multiple visitors simultaneously accessing a URL address, therefore, it can be used to test the load pressure on the target server. In general, the AB tool is small and simple, and quick to learn. It can provide basic performance indicators, but it does not have graphical results and cannot be monitored.

Syntax and Parameters

Usage: AB [options] [http [s]: //] hostname [: port]/path Usage: AB [Option] address option: Options are: -n requests # number of requests executed, that is, the total number of requests initiated. -C concurrency # number of concurrent requests. -T timelimit # maximum number of seconds for the test. The internal implicit value is-n 50000, which limits the server test to a fixed total time. By default, there is no time limit. -S timeout # specify the timeout time for each request. The default value is 30 seconds. -B windowsize # specify the tcp Window Size in bytes. -B address # specify the IP address bound when the connection is initiated. -P postfile # specify the file to be POST and set the-T parameter. -U putfile # specify the object to be PUT and set the-T parameter. -T content-type # specifies the text type when using POST or PUT to upload text. The default value is 'text/plain '. -V verbosity # sets the verbose mode level. -W # output the result to the html table. -I # use the HEAD method instead of GET to initiate a request. -Y attributes # sets the tr attribute of the html table when outputting data as a table. -Z attributes # sets the th or td attribute of the html table when outputting data as a table. -C attribute # Add a cookie, for example, 'apache = 123 '. (Repeated)-H attribute # append an additional header to the request, for example, 'Accept-Encoding: gzip '. (Repeated)-A attribute # provides BASIC authentication trust to the server. 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. -P attribute # 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 # specifies the IP address and port of the proxy server. -V # print the version information. -K # enable the HTTP KeepAlive function, that is, to execute multiple requests in an HTTP session. By default, KeepAlive is not enabled. -D # messages that do not display "percentage served within XX [MS] table" (supported for previous versions ). -Q # If the number of requests processed exceeds 150, each time AB processes about 10% or 100 requests, it will output a progress count in stderr. This q mark can suppress this information. -G filename # Write all test results to a 'gnuplot' or TSV (separated by tabs) file. This file can be easily imported to Gnuplot, IDL, Mathematica, Igor or even Excel. The title of the first behavior. -E filename # generate a comma-separated (CSV) file that contains the requirements for processing each percentage of requests (from 1% to 100%) (In subtle units. This format has been "binary", so it is more useful than the 'gnupload' format. -R # Do not exit when an error is received. -H # output help information-Z ciphersuite specifies the SSL/TLS cipher suite-f protocol specifies the SSL/TLS protocol (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

Example and result analysis
Initiate a request www.baidu.com with a concurrency of 10 and a total of 100, as shown below:

[Root @ jia1 ~] # AB-n 100-c 10 http://www.baidu.com/This is apachevision, Version 2.3 <$ Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking www.baidu.com (be patient )..... doneServer Software: BWS/1.1 Server Hostname: www. baidu. comServer Port: 80 Document Path:/# test page Document Length: 112439 bytes # Test page size Concurrency Level: 10 # number of concurrent calls Time taken for tests: 1.256 seconds # Time of the entire Test Call Complete requests: 100 # Total number of requests completed Failed requests: 96 # number of failed requests (Connect: 0, Receive: 0, Length: 96, Exceptions: 0) Write errors: 0 Total transferred: 11348660 bytes # Total size of transmitted data HTML transferred: 11253726 bytes # total transfer page size Requests per second: 79.62 [#/sec] (mean) # average number of Requests per second Time per request: 125.593 [MS] (mean) # average processing Time of 10 concurrent requests per Time pe R request: 12.559 [MS] (mean, internal SS all concurrent requests) # average processing time for each request, all concurrent requests plus Transfer rate: 8824.29 [Kbytes/sec] received # average network traffic per second Connection Times (MS) min mean [+/-sd] median maxConnect: 4 20 7.7 18 38 Processing: 18 90 50.5 82 356 Waiting: 4 22 7.9 22 41 Total: 22 111 50.7 101 # Connect, process Processing, wait for the minimum min of Waiting time, average mean, standard deviation [+/-sd], median, a table with the maximum table max. Percentage of the requests served within a certain time (MS) 50% 101 # 50% request response time within 101ms 66% 103 # 66% request response time within 103ms 75% 104 #... similarly, 80% 105 90% 111 95% 267 98% 311 99% 384 100% 384 (longest request)

We can see that www.baidu.com is used for testing and the error rate is very high. This should be related to www.baidu.com. Under normal circumstances, the error rate is not so high.
But I understand how to analyze it.
Supplement the data for testing www.sina.com. The total number of 100 concurrent requests is 20. The failure is 0. the following:

[root@jia1 ~]# ab -n 100 -c 20 http://www.sina.com/This is ApacheBench, Version 2.3 <$Revision: 1430300 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking www.sina.com (be patient).....doneServer Software:        nginxServer Hostname:        www.sina.comServer Port:            80Document Path:          /Document Length:        178 bytesConcurrency Level:      20Time taken for tests:   0.081 secondsComplete requests:      100Failed requests:        0Write errors:           0Non-2xx responses:      100Total transferred:      71200 bytesHTML transferred:       17800 bytesRequests per second:    1231.15 [#/sec] (mean)Time per request:       16.245 [ms] (mean)Time per request:       0.812 [ms] (mean, across all concurrent requests)Transfer rate:          856.03 [Kbytes/sec] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        2    6   2.5      6      14Processing:     3    7   3.2      5      14Waiting:        3    6   2.7      5      14Total:          7   13   3.8     12      23Percentage of the requests served within a certain time (ms)  50%     12  66%     14  75%     15  80%     16  90%     17  95%     21  98%     21  99%     23 100%     23 (longest request)

In addition, AB is a lightweight stress testing tool and the results are not very accurate and can be used as a reference.
For accuracy, jmeter or LoadRunner is recommended.

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.