AB (apachebench) is Apache's own Hypertext Transfer Protocol (HTTP) performance test tool. Its design intent is to depict the execution performance of the currently installed Apache, mainly showing how many requests Apache can process per second.
This tool is a tool that comes with Apache. With the Apache Http Server installed, the Ab.exe program is available.
After installation, there are ab.exe programs in the Apache Bin directory. This is our AB tool.
How to use the AB tool:
C: >CD C:\Program Files (x86) \apache software Foundation\apache2.2\bin
C:\Program Files (x86) \apache software Foundation\apache2.2\bin>ab
Ab:wrong Number of arguments
Usage:ab [Options] [http://]hostname[:p Ort]/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
is a colon separated username and password.
-P attribute Add Basic Proxy authentication, the attributes
is 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)
C:\Program Files (x86) \apache software foundation\apache2.2\bin>
Example:
C:\Program Files (x86) \apache software foundation\apache2.2\bin>ab-n 1000-c /archive/2010/05/25/5622268.aspx
--Note that a specific page is to be written here
This is apachebench, Version 2.3 < $Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus technology LTD, http://www.zeustech.net/
Licensed to the Apache software Foundation, http://www.apache.org/
Benchmarking blog.csdn.net (Be patient)
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Finished requests
Server software:nginx/0.7.65
Server Hostname:blog.csdn.net
Server port:80
Document Path:/tianlesoftware/archive/2010/05/25/5622268.aspx--Request Resource
Document length:169 Bytes--Length of documents returned, excluding corresponding headers
Concurrency level:50--Number of concurrent
Time taken for tests:118.549 seconds--Total request consumption
Complete requests:1000--total number of requests
Failed requests:1
(Connect:1, receive:0, length:0, exceptions:0)
Write errors:0
Non-2xx responses:1000
Total transferred:334000 bytes
HTML transferred:169000 bytes
Requests per second:8.44 [#/sec] (mean)-average number of requests per second
Time per request:5927.439 [MS] (mean)-average per request
Time per request:118.549 [MS] (mean, across all concurrent requests)
--Average each request time divided by the number of concurrent, this is 5927.439/50
Transfer rate:2.75 [Kbytes/sec] Received--time transfer rate
Connection Times (MS)
Min MEAN[+/-SD] Median max
CONNECT:47 97 72.8 63 742
processing:57 5720 4597.9 4666 25381
waiting:54 2711 3312.5 2128 25176
total:112 5817 4595.1 4754 25435
Percentage of the requests served within a certain time (MS)
50% 4754--
66% 5491
75% 6005
80% 6274
90% 7366
95% 8697
98% 25232
99% 25415
100% 25435 (Longest request)
C:\Program Files (x86) \apache software foundation\apache2.2\bin>
Meaning: Process 50 concurrent requests simultaneously and run 1000 times:
/tianlesoftware/archive/2010/05/25/5622268.aspx
Result: In the case of concurrent 50 requests, 1000 access requests were completed, which took 118.549 seconds, and the program could process 8.44 requests per second.
1, using AB, send post data:
Apachebench, there's a lot of information online
But it even includes foreign articles and official documents.
There's nothing more detailed out of the help display.
To use AB for post data testing. From help you can see that we need to define two of content
One is the-p parameter. Specify data that needs to be post
There is also a-t parameter that specifies the Content-type used
I simply wrote a script on the server side. Output the acquired POST request to a 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);
?>
Then generate the Post.txt file locally
Content is TEST=ABC
Use AB for testing
Ab-n 1-p post.txt http://192.168.0.2/test.php
Discovery server side received request, but no data received by post
After using the type. It's still not working.
Ab-n 1-p post.txt-t ' text/html ' http://192.168.0.2/test.php
Test with Get mode
Ab-n 1 HTTP://192.168.0.2/TEST.PHP?TEST=ABC
The server side will work properly
It's the same as it started. Google didn't find it.
Finally, we can only grab the bag with Wireshark
Finally found that Content-type must be set to become
application/x-www-form-urlencoded
Finally, the following test was done.
Ab-n 1-p post.txt-t ' application/x-www-form-urlencoded ' http://192.168.0.2/test.php
and a postfile.
If you have more than one record
Content can be written
Test1=a&test2=b
Like this, you can
This is also not mentioned in the document, let me first think postfile format is wrong.
A format has been mentioned online
Test1=a
Test2=b
This is wrong.
This ab will put the whole
A Enter test2=b
Send it out as a test1 field.
2, send get data using AB
Directly add the URL address, double quotation marks if "HTTP://TEST.QQ/?C=INDEX&R=104717283&SID=DSHRB6ZKP0TWTOOWIIM5"
Apache's own Ab.exe test site concurrency (site stress test)