ab – Apache HTTP server benchmarking tool

ab è un tool per poter effettuare i benchmark all’Apache Hypertext Transfer Protocol (HTTP) server. E’ utile per poter testare e mettere sotto stress la vostra istallazione di Apache e vedere quante richieste per secondo è capace di soddisfare.

Lista delle opzioni:

-A auth-username:passwordSupply BASIC Authentication credentials to the server. The username and password are separated by a single : and sent on the wire base64 encoded. The string is sent regardless of whether the server needs it (i.e., has sent an 401 authentication needed).

-b windowsizeSize of TCP send/receive buffer, in bytes.

-c concurrency Number of multiple requests to perform at a time. Default is one request at a time.

-C cookie-name=valueAdd a Cookie: line to the request. The argument is typically in the form of a name=value pair. This field is repeatable.

-d Do not display the “percentage served within XX [ms] table”. (legacy support).

-e csv-fileWrite a Comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests. This is usually more useful than the ‘gnuplot’ file; as the results are already ‘binned’.

-f protocolSpecify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL).

-g gnuplot-fileWrite all measured values out as a ‘gnuplot’ or TSV (Tab separate values) file. This file can easily be imported into packages like Gnuplot, IDL, Mathematica, Igor or even Excel. The labels are on the first line of the file.

-h Display usage information.

-H custom-headerAppend extra headers to the request. The argument is typically in the form of a valid header line, containing a colon-separated field-value pair (i.e."Accept-Encoding: zip/zop;8bit").

-i Do HEAD requests instead of GET.

-k Enable the HTTP KeepAlive feature, i.e., perform multiple requests within one HTTP session. Default is no KeepAlive.

-n requests Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results.

-p POST-fileFile containing data to POST. Remember to also set -T.

-P proxy-auth-username:passwordSupply BASIC Authentication credentials to a proxy en-route. The username and password are separated by a single : and sent on the wire base64 encoded. The string is sent regardless of whether the proxy needs it (i.e., has sent an 407 proxy authentication needed).

-q When processing more than 150 requests, ab outputs a progress count on stderr every 10% or 100 requests or so. The -q flag will suppress these messages.

-r Don’t exit on socket receive errors.

-sWhen compiled in (ab -h will show you) use the SSL protected https rather than the http protocol. This feature is experimental andvery rudimentary. You probably do not want to use it.

-S Do not display the median and standard deviation values, nor display the warning/error messages when the average and median are more than one or two times the standard deviation apart. And default to the min/avg/max values. (legacy support).

-t timelimitMaximum number of seconds to spend for benchmarking. This implies a -n 50000 internally. Use this to benchmark the server within a fixed total amount of time. Per default there is no timelimit.

-T content-typeContent-type header to use for POST/PUT data, eg. application/x-www-form-urlencoded. Default: text/plain.

-u PUT-fileFile containing data to PUT. Remember to also set -T.

-v verbositySet verbosity level – 4 and above prints information on headers, 3 and above prints response codes (404, 200, etc.), 2 and above prints warnings and info.

-V Display version number and exit.-wPrint out results in HTML tables. Default table is two columns wide, with a white background.

-x <table>-attributesString to use as attributes for <table>. Attributes are inserted <table here >.

-X proxy[:port]Use a proxy server for the requests.

-y <tr>-attributesString to use as attributes for <tr>.

-z <td>-attributesString to use as attributes for <td>.

-Z ciphersuiteSpecify SSL/TLS cipher suite (See openssl ciphers).

[FONTE]: http://httpd.apache.org/docs/2.2/programs/ab.html


## Esempio ##


Nel test che stiamo per lanciare, andremo a testare l’url: http://url_sito.it:31004/path con un numero di richieste pari a 500.

ab -n 500 http://url_sito.it:31004/path


Qui di seguito il suo risultato:

Benchmarking dev.subito.it (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests
Server Software: Apache
Server Hostname: url_sito.it
Server Port: 31004

Document Path: /path
Document Length: 11197 bytes

Concurrency Level: 1
Time taken for tests: 74.454 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 5838000 bytes
HTML transferred: 5598500 bytes
Requests per second: 6.72 [#/sec] (mean)
Time per request: 148.909 [ms] (mean)
Time per request: 148.909 [ms] (mean, across all concurrent requests)
Transfer rate: 76.57 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 7 136 307.2 68 5537
Processing: 0 13 38.0 3 341
Waiting: 0 11 37.7 0 337
Total: 65 149 306.9 70 5538

Percentage of the requests served within a certain time (ms)
50% 70
66% 86
75% 111
80% 140
90% 299
95% 388
98% 1139
99% 1161
100% 5538 (longest request)


## Esempio più complicato ##

Ora andiamo a testare un url, dove il numero delle richieste sarà sempre 500, ma aggiungiamo un ulteriore opzione, la concorrenza o numero di richieste multiple (-c).


ab -n 500 -c 50 http://url_sito.it:31004/path

Questo significa che verranno effettuate 500 richieste suddivise in blocchi di 50 per volta

## Esempio con parametri ##

Ora effettueremo un test passando dei parametri in POST. Come si può notare è sato aggiunto il parametro T (content-type).

ab -n 50 -T text/html -P email=username@email.it,password=password123 http://url_sito/path



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...