Apache Performance Testing

By | | Open Source

3

I have been starting to work with ab – included with Apache and not a new tool. ab allows for performance testing of web pages, sites and even dynamic scripts based on user load.

ab enables the creation of single or multiple requests per second and provides a nice results report.

Some of the key options, which can be viewed by running ‘man ab’ on any Linux or OS X installation with Apache installed.

Options:

-k: This enables HTTP KeepAlive so that multiple requests are carried out wihtin one session.

-n: Number of requests to perform, as in 150. They will be issued one after another until done.

-t: Issues a time limit on the time frame wihtin which the requests can be carried out.

-c: Allows for multiple requests simultaneously rather than one at a time. This can be good to test script performance.

-A username and password separated by a colon: This is used to send authentication if login is required on the site you are testing.

There are several other options including working through proxy servers, adding headers and cookies.

Results are output to the command line (example below from an OS X localhost Apache install):

This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3 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 localhost (be patient).....done Server Software: Apache/1.3.33 Server Hostname: localhost Server Port: 80 Document Path: / Document Length: 1456 bytes Concurrency Level: 1 Time taken for tests: 1.103 seconds Complete requests: 50 Failed requests: 0 Broken pipe errors: 0 Total transferred: 93500 bytes HTML transferred: 72800 bytes Requests per second: 45.33 [#/sec] (mean) Time per request: 22.06 [ms] (mean) Time per request: 22.06 [ms] (mean, across all concurrent requests) Transfer rate: 84.77 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.3 0 3 Processing: 12 21 60.0 12 438 Waiting: 12 21 59.8 12 436 Total: 12 21 60.4 12 441 Percentage of the requests served within a certain time (ms) 50% 12 66% 13 75% 13 80% 13 90% 14 95% 17 98% 441 99% 441 100% 441 (last request)

You can also output the results to a CSV file using a ‘-e filename’ option. ‘-w’ outputs the results to an HTML table. There is the ability to leverage ab from within PHP so as to generate load tests from a web browser and return results, though I have not attempted this as of yet. Primarily I have been running ab on development servers prior to a shift to production — and then running it again in the production environment prior to release.

Written By:

Blane Warrene

Blane is a writer and researcher focusing on Apple and Open Source technologies. Prior to this, he helped found a commercial software and consulting venture, and worked in the financial services sector as a director of technology and in varying technical roles. Blane maintains Open Sourcery: SitePoint's Open Source Blog.

Website
>> More Posts By Blane Warrene

 

{ 3 comments }

Buddha443556 March 14, 2005 at 11:50 am

If you really want to test your application performance and you are hosted on the shared server, try Apache JMeter (check JMeter homepage).

JMeter looks like a very flexiable load tester. I could probably create a test plan with JMeter that could pass without notice on a shared server. Isn’t like you actually need to even create load because shared servers are usually near or at or over load most of the time anyway.

However, load testing on a shared server is a big no-no. Mistakes could get an account suspended.

Thanks for the idea though.

Martin63 March 14, 2005 at 7:55 am

If you really want to test your application performance and you are hosted on the shared server, try Apache JMeter (check JMeter homepage). It is also OS project. You will have no difficulties to master it. Excellent community support is available. It is worth trying. Of-course, the results are deformed because of

Buddha443556 March 14, 2005 at 7:17 am

Man page for ab with complete list of options. Wish I could run this in my production environments but as it’s shared hosting I’m out of luck. But my test server has no hard drive cache so it’s almost as good. ;-)

Comments on this entry are closed.