Instructions for using the AB tool
1. Install the AB tool command
sudo apt-get install apache2-utils
2.AB command parameter Description
Usage:ab [Options] [http[s]://]hostname[:p Ort]/path
Options are:
// Number of requests
- N requests number of requests to perform
Concurrency number
-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
Post file (with Post data), colleague set-T
-P postfile File containing data to POST. Remember also to Set-t
-U putfile File containing data to PUT. Remember also to Set-t
Set the content type header for post
-T Content-type content-type header for POSTing, eg.
' Application/x-www-form-urlencoded '
Default is ' Text/plain '
Printing troubleshooting information
-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
Set cookies
-C attribute Add cookie, eg. ' Apache=1234. (repeatable)
Set header row
-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)
-Z ciphersuite Specify SSL/TLS cipher suite (see OpenSSL ciphers)
-F Protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or all)
3. How to use
Run ab-n 100-c http://keketour.me/
the http://keketour.me/ The site makes 100 requests, and 10 requests concurrently
pressure Test Results
Server software:lighttpd/1.4.20
Server Hostname:www.meetu.hk
Server port:80
Document Path:/
Document length:2095 bytes
Concurrency level:10
Duration of the entire test
Time taken for tests:3.303 seconds
Number of requests completed
Complete requests:100
Failed requests:0
Write errors:0
Total transferred:235200 bytes
HTML transferred:209500 bytes
Average of 30 requests per second
Requests per second:30.27 [#/sec] (mean)
//average per request processing time is 330 milliseconds Note: Here, 10 concurrent requests are considered as a whole
Time per request:330.335 [MS] (mean)
Average processing time per concurrent request is 33 milliseconds
Time per request:33.034 [MS] (mean, across all concurrent requests)
Transfer rate:69.53 [Kbytes/sec] Received
Connection Times (MS)
Min MEAN[+/-SD] Median max
CONNECT:51 170 35.9 178 230
Processing:60 153 64.5 121 263
Waiting:55 148 64.4 115 258
TOTAL:235 322 59.9 299 437
Percentage of the requests served within a certain time (MS)
//50% of these 100 requests are completed in 299 milliseconds
50% 299
Of these 100 requests, 66% were completed in 312 milliseconds.
66% 312
75% 383
80% 412
90% 431
95% 432
98% 436
99% 437
100% 437 (Longest request)
Attention:
When simulating a login, you only need to set a cookie:
1. After logging in with your account and password, use the Developer tool to find the cookie value (session ID) that identifies the session.
2. If only one cookie is used, simply type the command:
ab-n 100-c 10-c jiang_token= 3820aab5-a395-48b2-8d2b-87bf47026e78
http://keketour.me/
If more than one cookie is required, set the header directly:
ab-n 100-h "cookie:key1=value1; Key2=value2 " http://keketour.me/
Test API interface (here is an example of adding a travel scheme)
ab-n 10-c 5-p/var/www/kkt/post.txt-v 3 - h "cookie:jiang_token=3820aab5-a395-48b2-8d2b-87bf47026e78; X-requested-with:xmlhttprequest " - t application/x-www-form-urlencoded" http://keketour.me/product/ Tourinfo/savetournameajax "
Where Post.txt is the post parameter text, the content is
name= Pressure Test Stroke Plan &tour_id=0&product_id=1382&_method=patch
Summarize:
AB Tool AB is small, simple, quick to learn, can provide the basic performance indicators needed, but no graphical results, can not be monitored. The AB tool can therefore be used as a temporary emergency task and as a simple test.
This article is from the "formerly Slow" blog, please be sure to keep this source http://onebig.blog.51cto.com/13006327/1981389
Instructions for using the Apache AB tool for stress testing