Apache Performance Tuning (Part III/III) – Measuring Apache’s Performance

I will introduce two benchmarking tools here: ab & httperf with some other utilities.

1. ab is shipped with most linux distributions. It is used to simulate load test on to your webserver and check how it behaves during such situations. It is run from the command line and the command is ab followed by the required options and the name of a website served by the server that you need to test. There are two ways to which you can run the test. One is to run the ab tool in the same machine where Apache is installed. The sencond is the practical way which is to run the tool to a remote webserver which helps in taking into account the network related accessibility issues. Lets see how to use it.

The most common options of ab are -n and -c. A test to www.google.com would be as below:

root@sage3-desktop:~# ab -n 100 -c 10 http://www.google.com/

This is ApacheBench, 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 www.google.com (be patient)…..done

Server Software: gws

Server Hostname: www.google.com

Server Port: 80

Document Path: /

Document Length: 221 bytes

Concurrency Level: 10

Time taken for tests: 1.455 seconds

Complete requests: 100

Failed requests: 0

Write errors: 0

Non-2xx responses: 100

Total transferred: 83000 bytes

HTML transferred: 22100 bytes

Requests per second: 68.72 [#/sec] (mean)

Time per request: 145.509 [ms] (mean)

Time per request: 14.551 [ms] (mean, across all concurrent requests)

Transfer rate: 55.70 [Kbytes/sec] received

Connection Times (ms)

min mean[+/-sd] median max

Connect: 45 49 3.2 48 62

Processing: 89 94 3.3 94 108

Waiting: 89 94 3.3 93 107

Total: 136 143 5.5 142 170

Percentage of the requests served within a certain time (ms)

50% 142

66% 144

75% 144

80% 145

90% 148

95% 155

98% 166

99% 170

100% 170 (longest request)

-n : 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.

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

Let me explain the options. -n denotes the total number of requests to send to the webserver in the ab session. By specifying -c 10 we ensure that at any instant of the ab session we keep the webserver busy with 10 requests until the total limit of 100 requests is reached. The requests may be sent through a single connection if the server permits KeepAlive and browser supports persistent connections. The main points in performace to note for are: Failed requests, Connection Times & Transfer rate.

2. httperf Usage :

httperf –hog –server www.google.com –num-conn 50 –rate 10 –timeout 5

-hog : Use as many TCP ports as necessary to generate stats

–server: the host. IP or hostname can be specified

–num-conn : number of connections to create for the session

–rate : create connections at the rate of 10 per second

More simple and direct usage examples can be found at the man page for httperf.

3. Apart from command line tools, there are online websites for analysing webserver performance:

http://www.webpagetest.org/

http://linuxbox.co.uk/website_performance_test.php

4. Page Speed by Google is an open-source project started at Google to help developers optimize their web pages by applying web performance best practices. Page Speed started as an open-source Firefox/Firebug add-on and is now deployed in third-party products such as Webpagetest.org, Show Slow and Google Webmaster Tools. Please see:

http://code.google.com/speed/page-speed/

Post to Twitter Tweet This Post

Continue Reading

About this blog

This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later