AB (ApacheBench) is Apache comes with Hypertext Transfer Protocol (HTTP) performance testing tool. It is designed to execution performance depicting Apache currently installed, the main number is a Apache requests per second.
The tool is a tool that comes with Apache. Installed Apache Http Server, there ab.exe program.
After installation, there ab.exe program in apache Bin directory. This is our AB tool.
AB use tools :( for ease of use, will join ab.exe directory environment variable)
C:\Users\admin >ab
ab: wrong number of arguments
Usage: ab [options] [http://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-b windowsize Size of TCP send/receive buffer, in bytes
-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 for POSTing, 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.
-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)
Example:
C:\Users\admin >ab -n 1000 -c 10 http://www.dayima.com/
C:\Users\admin>ab -n 1000 -c 10 http://www.dayima.com/
This is ApacheBench, Version 2.3 <$Revision: 1748469 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.dayima.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.11.5
Server Hostname: www.dayima.com
Server Port: 80
Document Path: /
Document Length: 2364 bytes
Concurrency Level: 10
Time taken for tests: 145.818 seconds
Complete requests: 1000
Failed requests: 20
(Connect: 0, Receive: 0, Length: 20, Exceptions: 0)
Non-2xx responses: 20
Total transferred: 3242246 bytes
HTML transferred: 2320180 bytes
Requests per second: 6.86 [#/sec] (mean)
Time per request: 1458.182 [ms] (mean)
Time per request: 145.818 [ms] (mean, across all concurrent requests)
Transfer rate: 21.71 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 1
Processing: 5 1451 215.8 1422 2482
Waiting: 3 1451 215.9 1422 2482
Total: 5 1451 215.8 1422 2483
Percentage of the requests served within a certain time (ms)
50% 1422
66% 1443
75% 1462
80% 1478
90% 1666
95% 1765
98% 2058
99% 2270
100% 2483 (longest request)
C:\Users\admin>
Use ab, post data transmission:
apachebench a lot of information online, but even including foreign articles and official documents beyond what the show would have no help a little bit in more detail some of the content, and to conduct post ab use test data can be seen from the help that we need define two content
a is -p parameter specifies the need for data post, and one -T parameter, content-type specified use, I simply wrote a script on the server side would get to the post to request output file.
<?php
echo $_REQUEST['test'];
$file=fopen('/data/www/log.txt','a+');
fwrite($file,date("Y-m-d H:i:s"));
fwrite($file,$_REQUEST['test']);
fclose($file);
Post.txt file is then generated locally, content test = abc, using test ab
ab -n 1 -p post.txt http://192.168.0.2/test.php
Discovery Server terminated by the request, but did not receive post data
after the type of use also does not work
ab -n 1 -p post.txt -T ‘application/x-www-form-urlencoded’ http://192.168.0.2/test.php
Use get way test