ab-Apache HTTP server benchmarking tool

http://httpd.apache.org/docs/2.0/programs/ab.html 

abIt is a tool for benchmarking Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how the current Apache installation is performing. This especially shows you how many requests per second the Apache installation can handle.

Overview

ab [ -A auth-username:password ] [ -c concurrency ] [ -C cookie-name=value ] [ -d ] [ -e csv-file ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [ -i ] [ -k ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-username:password ] [ -q ] [ -s ] [ -S ] [ -t timelimit ] [ -T content-type ] [ -v verbosity] [ -V ] [ -w ] [ -x <table>-attributes ] [ -X proxy[:port] ] [ -y <tr>-attributes ] [ -z <td>-attributes ] [http://]hostname[:port]/path

Options

-A auth-username:password

Provide BASIC authentication credentials to the server. The username and password are separated by a single, :and sent through the network encoded as base64. The string will be sent regardless of whether the server requires the string ( ie , the required 401 authentication has been sent).

-c concurrency

The number of multiple requests executed at once. The default value is one request at a time.

-C cookie-name=value

Cookie:Add a line to the request. The parameters are usually in the form of a pair. This field is repeatable.name=value

-d

Don’t show "Delivery Percentage in XX [ms] Table". (Legacy support).

-e csv-file

Write a comma-separated value (CSV) file that contains the time (in milliseconds) spent serving that percentage of requests for each percentage (from 1% to 100%). Generally, it is more useful than "gnuplot" files. Because the result has been "boxed".

-g gnuplot-file

Write all measured values ​​as "gnuplot" or TSV (Tab Separate Values) files. This file can be easily imported into software packages such as Gnuplot, IDL, Mathematica, Igor and even Excel. The label is on the first line of the file.

-h

Display usage information.

-H custom-header

Add additional headers to the request. This parameter is typically in the form of a valid header line, containing a colon-separated field value pair ( ie , "Accept-Encoding: zip/zop;8bit").

-i

Make a HEADrequest instead GET.

-k

Enable the HTTP KeepAlive function, that is , execute multiple requests in an HTTP session. The default is no KeepAlive.

-n requests

The number of requests executed for the benchmark session. The default setting is to execute only one request, which usually leads to non-representative benchmark results.

-p POST-file

The file containing the data to be published.

-P proxy-auth-username:password

Provide BASIC authentication credentials on the way to the agent. The username and password are separated by a single, :and sent through the network encoded as base64. This string will be sent regardless of whether the proxy requires it ( ie , the required 407 proxy authentication has been sent).

-q

When processing more than 150 requests, the abprogress count is output for every 10% or about 100 requests stderr. This  -qflag will suppress these messages.

-s

When compiling as ( ab -hwill be shown to you), please use SSL protection httpsinstead of httpprotocol. This feature is experimental and very basic. You may not want to use it.

-S

When the average and median are one or more times the standard deviation, do not display the median and standard deviation values, and will not display warning/error messages. And the default is the minimum/average/maximum value. (Legacy support).

-t timelimit

The maximum number of seconds used for benchmarking. This means  -n 50000internal. Use it to benchmark the server in a fixed total time. There is no time limit by default.

-T content-type

The content type header used for POST data.

-v verbosity

Set the level of detail- 4information 3will be displayed on the title at the top, response codes (404, 200, etc.)  2will be displayed at the top, warnings and messages will be displayed at the top.

-V

Display the version number and exit.

-w

Print out the results in an HTML table. The default table is two columns wide with a white background.

-x <table>-attributes

The string used as the attribute <table>. Insert attributes.<table here >

-X proxy[:port]

Use a proxy server to process the request.

-y <tr>-attributes

The string used as the attribute <tr>.

-z <td>-attributes

The string used as the attribute <td>.

 

BUG

There are various statically declared buffers of fixed length. Combined with the delayed parsing of command line parameters, the server's response headers, and other external input, this may cause you trouble. It does not fully implement HTTP/1.x. Only accept certain "expected" forms of response. strstr(3)The heavy usage display at the top of the profile may indicate performance issues; that is , you will measure abperformance rather than server performance.

Concurrent stress test example

Send 1000 http get requests to [ http://192.168.10.232:8000/blog , the concurrent is 10]:

$ ab -n1000 -c10 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
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)
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.10.3
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        11321 bytes

Concurrency Level:      10
Time taken for tests:   0.066 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      11566000 bytes
HTML transferred:       11321000 bytes
Requests per second:    15207.74 [#/sec] (mean)
Time per request:       0.658 [ms] (mean)
Time per request:       0.066 [ms] (mean, across all concurrent requests)
Transfer rate:          171770.21 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:     0    0   0.1      0       1
Waiting:        0    0   0.2      0       1
Total:          0    1   0.1      1       1

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      1
  98%      1
  99%      1
 100%      1 (longest request)

Note that Time per request: 0.658 [ms] (mean) is the average completion time of each batch of requests, here is the time to complete 10 requests. Time per request: 0.066 [ms] (mean, across all concurrent requests) is the average completion time of each request.

ApacheBench will only use one operating system thread. In many cases, ApacheBench itself is the bottleneck. When using ApacheBench in hardware with multiple processor cores, it is recommended that one cpu core execute one ab thread, but now that there are many cpu cores, such as 48 cores, manually executing 48 commands is also a personal effort.

On the whole, ab is only suitable for rough testing of a single component, such as Apache http, because it cannot use multiple cores, cannot be parameterized, and does not support protocols other than http and https. It is not suitable for business-level testing. For example, once there is a database in the background, the ab test is almost meaningless.

 

Guess you like

Origin blog.csdn.net/boonya/article/details/109684160