Nov 21, 2009

Performance Benchmarks a Webserver

ApacheBench is a command line computer program for measuring the performance of HTTP web servers, in particular the Apache HTTP Server. It was designed to give an idea of the performance that a given Apache installation can provide. In particular, it shows how many requests per second the server is capable of serving.

The ab tool comes bundled with the standard Apache source distribution, and like the Apache web server itself, is free, open source software and distributed under the terms of the Apache License.

The performance is usually measured in terms of:

  • Number of requests that can be served per second (depending on the type of request, etc.);
  • Latency response time in milliseconds for each new connection or request;
  • Throughput in bytes per second (depending on file size, cached or not cached content, available network bandwidth, etc.).

The measurements must be performed under a varying load of clients and requests per client.

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



Supply 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



-c concurrency



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



-C cookie-name= value



Add 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-file



Write 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'.



-g gnuplot-file



Write 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-header



Append 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-file



File containing data to POST.



-P proxy-auth-username: password



Supply 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.



-s



When compiled in (ab -h will show you) use the SSL protected https rather than the http protocol. This feature is experimental and very 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 timelimit



Maximum 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-type



Content-type header to use for POST data.



-v verbosity



Set 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.



-w



Print out results in HTML tables. Default table is two columns wide, with a white background.



-x <table>-attributes



String to use as attributes for <table>. Attributes are inserted <table here >.



-X proxy[: port]



Use a proxy server for the requests.



-y <tr>-attributes



String to use as attributes for <tr>.



-z <td>-attributes



String to use as attributes for <td>.



Apache Benchmark Procedures




  • First record server load using top or uptime command


  • Take at least 3-5 readings and use the best result


  • After each test reboot the server and carry out test on next configuration (web server)


  • Again record server load using top or uptime command


  • Carry on test using static html/php files and dynamic pages


  • It also important to carry out test using the Non-KeepAlive and KeepAlive (the Keep-Alive extension to provide long-lived HTTP sessions, which allow multiple requests to be sent over the same TCP connection) features



Note down server load using uptime command

$ uptime



Create a static (small) html page as follows (snkpage.html) (assuming that server IP is 202.54.200.1) in /var/www/html (or use your own webroot):




<html>
<head>
<title>Webserver test</title>
</head>
<body>
This is a webserver test page.
</body>
</html>



Login to Linux/bsd desktop computer and type following command:



$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html 



Where,




  • -n 1000: ab will send 1000 number of requests to server 202.54.200.1 in order to perform for the benchmarking session


  • -c 5 : 5 is concurrency number i.e. ab will send 5 number of multiple requests to perform at a time to server 202.54.200.1


  • For example if you want to send 10 request, type following command:

    $ ab -n 10 -c 2 http://www.somewhere.com/



Output




This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0 
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.cyberciti.biz (be patient).....done
Server Software:
Server Hostname: www.somewhere.com
Server Port: 80
Document Path: /
Document Length: 16289 bytes
Concurrency Level: 1
Time taken for tests: 16.885975 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 166570 bytes
HTML transferred: 162890 bytes
Requests per second: 0.59 [#/sec] (mean)
Time per request: 1688.597 [ms] (mean)
Time per request: 1688.597 [ms] (mean, across all concurrent requests)
Transfer rate: 9.59 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 353 375 16.1 386 391
Processing: 1240 1312 52.1 1339 1369
Waiting: 449 472 16.2 476 499
Total: 1593 1687 67.7 1730 1756
Percentage of the requests served within a certain time (ms)
50% 1730
66% 1733
75% 1741
80% 1753
90% 1756
95% 1756
98% 1756
99% 1756
100% 1756 (longest request)



Repeat above command 3-5 times and save the best reading.



Use -k option that enables the HTTP KeepAlive feature using ab test tool. For example:



$ ab -k -n 1000 -c 5 http://202.54.200.1/snkpage.html



Use -e option that allows to write 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:



$ ab -k -n 50000 -c 2 -e apache2r1.cvs http://202.54.200.1/snkpage.html 



After displaying some status reports every 100 requests or so, it will print out a fairly detailed report, including document length, bytes transferred, completed and failed requests, requests per second and some statistics on connection times.


0 comments:

Text Widget

Copyright © Vinay's Blog | Powered by Blogger

Design by | Blogger Theme by