Http://httpd.apache.org/docs/2.0/programs/ AB .html
In website development, sometimes you need to perform performance tests on the website and the response time of the Zhidao website under a certain number of concurrent accesses. Here we will introduce a tool of Apache, Apache benchmark, you can easily perform some performance tests on your website.
Introduction:
Apache benchmark is an auxiliary software for Apache HTTP Server httpd. After the httpdserver is installed at http://httpd.apache.org/, you will find AB .exe IN THE bindirectory,
Run AB-h. The complete description of AB is as follows:
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 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)
For the most basic usage, suppose there is a local http: // localhost/phptest. php display phpinfo, you can use the-C and-N parameters,
Run the following command to test the performance data when the number of concurrent requests is 10 and the total number of requests is 100,
AB-N 1000-C 100 http: // localhost/phptest. php
The test results on my local machine are as follows:
This is apachetings, 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 localhost (Be patient)
Server Software: Apache/2.2.14
Server Hostname: localhost
Server port: 80
Document path:/phptest. php
Document length: 43931 bytes
Concurrency level: 100
Time taken for tests: 7.563 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 44099000 bytes
HTML transferred: 43931000 bytes
Requests per secondd: 132.23 [#/sec] (mean)
Time per request: 756.250 [MS] (mean)
Time per request: 7.563 [MS] (mean, internal SS all concurrent requests)
Transfer Rate: 5694.60 [Kbytes/sec] canceled ed
Connection times (MS)
Min mean [+/-SD] median Max
Connect: 0 4 16.3 0 469
Processing: 203 706 247.4 656 1547
Waiting: 172 381 168.9 328
Total: 203 710 248.1 656
Percentage of the requests served within a certain time (MS)
50% 656
66% 688
75% 688
80% 719
90% 1172
95% 1375
98% 1422
99% 1453
100% 1563 (longest request)
The result is relatively simple, with emphasis on the red part. It means that 100 requests are completed under 1000 concurrent requests, which takes 7.5 seconds in total and 1000 requests are completed without failure, the average time is 710 milliseconds, and the standard deviation is 248 milliseconds. The median [50% request time] is 656 milliseconds, and the 90% request time is 1172 milliseconds, that is, 1.172 seconds. The slowest request uses 1.563 seconds;
Basically, you can adjust the-N and-C parameters to determine the concurrency supported by the system.
In addition, if it is a dynamic page, such as a page that can only be viewed after login, You can first open the page in Firefox, and then View session-related cookies through firebug, then, use the-C parameter to specify it, and you can assume that the user has logged on to the system:
AB-C 100-N 1000-C JSESSIONID = 1cbdb188ab4c901c2c3dc2c5baea1f47 http: // localhost: 9080/MyApp
Of course, AB has many defects, such as the inability to simulate different types of users to perform different operations, the inability to simulate actual user thinking times, and the lack of graphical tools to display results. Some other tools overcome these defects.