[Go] Apachebench (AB) of Web Performance stress testing tool

Source: Internet
Author: User
Tags response code

PS: Site 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.

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
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.
-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 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
A file that contains the data that needs to be post, such as "p1=1&p2=2". The method of use is-P 111.txt. (with-T)
-T Content-type content-type header for POSTing
The Content-type header information 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 verbosity of the display information –4 or greater displays header information, 3 or greater values can display a response code (404, 200, and so on), 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
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 of GET
Executes 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″ (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)
#最重要的指标之一, 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)
# The two most important indicators are equivalent to the average transaction response time in LR, and the mean in parentheses below indicates that this is an average of
time per request:2.961 [MS] (mean, across all concurrent requests)
#每个连接请求实际运行时间的平均值
Transfer rate:16866.07 [kbytes/sec] received
#平均每秒网络上的流量, you can help troubleshoot problems with extended response time due to excessive network traffic
Connection Times (ms)
Min MEAN[+/-SD] median max
connect:0 483 1773.5 9052
Processing:2 556 1459.1 255 11763
waiting:1 515 1459.8 275 11756
total:139 1039 2296.6 1184 3
#网络上消耗的时间的分解, the specific algorithm for each data is not very 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.

[Go] Apachebench (AB) of Web Performance stress testing tool

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.