Web page performance testing tools ApacheBench and WebBench
200 02018-01-02 Linux/Unix, Network Common Sense, Software Testing
Web page performance testing tools under Linux: ApacheBench and WebBench
1. ApacheBench
Ab pressure tool installation
Ab is a performance testing tool for apache. It can only install ab tools and support http and https pages.
Ubuntu installation: sudo apt-get -y install apache2-utils
CentOS installation: sudo yum -y install httpd-tools
Detailed explanation of the ab parameter
Format: ab [options] [http[s]://]hostname[:port]/path
Example: ab -n 1000 -c 100 https://mimvp.com/
parameter:
-n The number of requests executed during the test session. Only one request is executed by default.
-c The number of requests generated at one time. The default is one request at a time; if it is 100, it means 100 requests each time.
-t The maximum number of seconds the test will take. Its internal implied value is -n 50000, which limits the testing of the server to a fixed total time. By default, there is no time limit.
-p Contains files that require POST data.
-P provides BASIC authentication trust to a transit agent. The username and password are separated by a : and sent in base64 encoding. This string is sent regardless of whether the server needs it (ie, whether the 401 authentication requirement code was sent).
-T Content-type header information used by the POST data.
-v Sets the level of detail of the displayed information -4 or greater to display header information, 3 or greater values to display response codes (404, 200, etc.), and 2 or greater values to display warnings and other information.
-V displays the version number and exits.
-w Outputs the result in the format of an HTML table. By default, it is a table of two column widths with a white background.
-i Executes a HEAD request instead of a GET.
-x Sets the string of the attribute.
-X Use a proxy server for the request.
-y Sets the string of the attribute.
-z Sets the string of the attribute.
-C Append a cookie to the request: line. Its typical form is a parameter pair of name=value, which can be repeated.
-H Append additional header information to the request. A typical form of this parameter is a valid header line containing a colon-separated pair of fields and values (eg, "Accept-Encoding:zip/zop;8bit").
-A Provides BASIC authentication trust to the server. The username and password are separated by a : and sent in base64 encoding. This string is sent regardless of whether the server needs it (ie, if the 401 authentication requirement code is sent).
-h shows how to use it.
-d Does not display the message "percentage served within XX [ms] table" (supported for previous versions).
-e Produces a comma-separated (CSV) file containing the corresponding (in subtle) time required to process each corresponding percentage of requests (from 1% to 100%). Since this format is already "binarized", it is more useful than the 'gnuplot' format.
-g Writes all test results to a 'gnuplot' or TSV (tab-delimited) file. This file can be easily imported into Gnuplot, IDL, Mathematica, Igor and even Excel. One of the first action titles.
-i Executes a HEAD request instead of a GET.
-k Enables the HTTP KeepAlive feature, which performs multiple requests in an HTTP session. By default, the KeepAlive feature is not enabled.
-q If the number of requests processed is greater than 150, ab will output a progress count on stderr each time approximately 10% or 100 requests are processed. This -q flag can suppress this information.
Complete help documentation (English)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| [root@mimvp-bj script] # ab -h Usage: ab [options] [http[s]: // ] hostname [:port] /path Options are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make at a time -t timelimit Seconds to max. to spend on benchmarking This implies -n 50000 -s timeout Seconds to max. wait for each response Default is 30 seconds -b windowsize Size of TCP send /receive buffer, in bytes -B address Address to bind to when making outgoing connections -p postfile File containing data to POST. Remember also to set -T -u putfile File containing data to PUT. Remember also to set -T -T content- type Content- type header to use for POST /PUT data, eg. 'application/x-www-form-urlencoded' Default is 'text/plain' - v verbosity How much troubleshooting info to print -w Print out results in HTML tables -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 -C attribute Add cookie, eg. 'Apache=1234' . (repeatable) -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. -q Do not show progress when doing more than 150 requests -g filename Output collected data to gnuplot format file . -e filename Output CSV file with percentages served -r Don't exit on socket receive errors. -h Display usage information (this message) -Z ciphersuite Specify SSL /TLS cipher suite (See openssl ciphers) -f protocol Specify SSL /TLS protocol (SSL3, TLS1, TLS1.1, TLS1.2 or ALL) |
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
-t timelimit Seconds to max. to spend on benchmarking
This implies -n 50000
-s timeout Seconds to max. wait for each response
Default is 30 seconds
-b windowsize Size of TCP send/receive buffer, in bytes
-B address Address to bind to when making outgoing connections
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header to use for POST/PUT data, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-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
-C attribute Add cookie, eg. 'Apache=1234'. (repeatable)
-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.
-q Do not show progress when doing more than 150 requests
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don't exit on socket receive errors.
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol
(SSL3, TLS1, TLS1.1, TLS1.2 or ALL)
POST request
### post data file user_login Content: {"email":"iloveyou@mimvp.com","password":"mimvp.com"}
Ab -n 100 -kc 10 -p user_login -T 'application/json' -H 'Accept-Encoding:gzip, deflate' -H 'accept-language:zh-Hans-CN;q=1, en-CN;q =0.9' https://mimvp.com/usercenter/login
Parameter Description:
-n 100 means request 100 times
-kc 10 means to keep HTTP KeepAlive one concurrent request 10 times
-p user_login represents the file requested by POST, json data format, as above {"email":"iloveyou@mimvp.com","password":"mimvp.com"}
-T 'application/json' Content-type header information used by POST data
-H 'Accept-Encoding:gzip, deflate' indicates that additional header information is requested, web compression algorithm
-H 'accept-language:zh-Hans-CN;q=1, en-CN;q=0.9' means to request additional header information, web page encoding
Https://mimvp.com/usercenter/login indicates the requested URL, such as Mipu Technology Homepage
GET request
Ab -n 1000 -c 100 https://mimvp.com/
The results are as follows:
Completed 1000 requests
Finished 1000 requests
Server Software: nginx
Server Hostname: mimvp.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2, ECDHE
Subscribe Our Newsletter
0
Post a Comment