Apachebench (AB) of Web performance stress testing tools

Source: Internet
Author: User
Tags server port

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.

Apachebench parameter Description

Format: AB [options] [http://]hostname[:p Ort]/path
Parameter description:
-N requests number of requests to perform
//Number of requests executed in the test session (the total number of times this test will visit the page). By default, only one request is executed.
-c concurrency number of multiple requests to make
//The number of requests produced at one time (number of concurrent). The default is one at a time.
-T TimeLimit Seconds to Max. Wait for responses
The maximum number of seconds that the//test takes. Its internal implied value is-n 50000. It allows you to limit the testing of the server to a fixed total time. By default, there is no time limit.
-P postfile File containing data to POST
//Contains files that require post data, with file formats such as "p1=1&p2=2". The method of use is-P 111.txt. (with-T)
-T Content-type content-type header for POSTing
//post The Content-type header information used by the data, such as-T "application/x-www-form-urlencoded". (with-P)
-V verbosity how much troubleshooting info to print
//Set the detail level of the display information –4 or greater displays header information, 3 or greater values can display response codes (404, 200, etc.), and 2 or greater values 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 with a two-column width on a white background.
-I use HEAD instead of GET
//Execute 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″ (repeatable)
//-c Cookie-name=value Attach a cookie to the request: line. Its typical form is a parameter pair of Name=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 and password.
-P attribute Add Basic Proxy authentication, the attributes
is a colon separated username and password.
//-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: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 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 realize the http/1.x completely; Accept only certain ' expected ' response formats. The frequent use of STRSTR (3) can lead to performance problems, i.e. you may be testing the performance of AB rather than the server.

a lot of parameters, generally we use the-C and-n parameters can be. For example:

# ab-c 5000-n http://127.0.0.1/index.php

Apachebench usage:

In the Linux system, the general installation of Apache can be directly executed;
# ab -n 4000 -c 1000 http://www.ha97.com/

If it is the win system, open the CMD Command Line window, CD to the Apache installation directory under the bin directory;

The 4000 after-N represents a total of 4,000 requests, and the 1000 after-c indicates 1000 concurrency (simulating 1000 simultaneous accesses), followed by URLs representing the target URLs of the tests.

Wait a moment to get a similar result as shown below:

Results Analysis:

This is Apachebench, Version 2.3
Copyright 1996 Adam Twiss, Zeus technology LTD, http://www.zeustech.net/
Licensed to the Apache software Foundation, http://www.apache.org/

Benchmarking 192.168.80.157 (Be patient)
completed-requests
completed requests
completed requests completed requests
completed requests
completed 2400 requests
completed 2800 requests
completed 3200 requests
completed 3600 requests
completed 4000 requests
finished 4000 requests

Server software:apache/2.2.15
Server hostname:192.168.80.157
Server port:80

Document Path:/phpinfo.php
#测试的页面
Document length:50797 bytes
#页面大小

Concurrency level:1000
#测试的并发数
Time taken for tests:11.846 seconds
#整个测试持续的时间
Complete requests:4000
#完成的请求数量
Failed requests:0
#失败的请求数量
Write errors:0
Total transferred:204586997 bytes
#整个过程中的网络传输量
HTML transferred:203479961 bytes
#整个过程中的HTML内容传输量
Requests per second:337.67 [#/sec] (mean)
#最重要的指标之一, which is equivalent to the number of transactions per second in LR, the mean in the parentheses below indicates that this is an average
Time per request:2961.449 [MS] (mean)
#最重要的指标之二, which is equivalent to the average transaction response time in LR, the mean in parentheses below indicates that this is an average
Time per request:2.961 [MS] (mean, across all concurrent requests)
#每个连接请求实际运行时间的平均值
Transfer rate:16866.07 [Kbytes/sec] Received
#平均每秒网络上的流量 to help troubleshoot problems with extended response times due to excessive network traffic
Connection Times (MS)
Min MEAN[+/-SD] Median max
connect:0 483 1773.5 11 9052
Processing:2 556 1459.1 255 11763
Waiting:1 515 1459.8 220 11756
total:139 1039 2296.6 275 11843
#网络上消耗的时间的分解, the specific algorithm of the data is not clear

Percentage Of the requests served within a certain time (ms)
50% 275
66% 298
75% 328
80% 373
90% 3260
95% 9075
98% 9267
99% 11713
100% 11843 (Longest request)
#整个场景中所有请求的响应情况. Each request in the scene has a response time, where 50% of the user's response time is less than 275 milliseconds, 66% of the user response time is less than 298 milliseconds, and the maximum response time is less than 11843 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 basically the first time of the request is approximately equal to the second time per requests multiplied by the number of concurrent requests.

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.


Apachebench (AB) of Web performance stress testing tools

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.