An assortment of indigestible things

Using ‘ab’ to benchmark with different (or random) requests

If you’ve ever needed to benchmark (or load test) a webserver, you’ll be familiar with Apache Benchmark (ab), a brilliant tool that will hammer your webserver with lots of concurrent requests and give you statistics, histograms and and graphs—everything apart from how hot the server got! This is useful to determine when things like the network and webserver processes hit some limit or other, but for a modern web application it is of limited use, because more than likely you’ll end up requesting a cached page over and over again.

Chris Miles (possibly an old blog, as there haven’t been any posts since 2009) wrote a patch which allows ab to take a list of request suffixes generated in advance, cycling through them repeatedly while it does its thing. This means that, if you can generate a long enough list, you can really stress every part of your web app without having to write a custom load-testing script. It’s one of those things that I wish I’d found a long time ago. It would have saved me many lines of code.

I’m mentioning it here because Chris’s patch is for Apache 2.2.4, which is now a little long in the tooth, so the chances are that your machine is running something quite a bit more recent. As time goes on, the code base will drift away from the patch, making it increasingly difficult to apply. Happily the older version is still available, and the distribution can be used to build a much-improved version of ab.

For the impatient

If you can’t be bothered messing around with building things, I present for your convenience a statically linked ab binary for 64-bit Linux compiled against the Apache 2.2.4 distribution with Chris’s patch. There; now you can stop reading and get to work (unless you need SSL — in which case, read on).

For the control freak

If you really want to build it yourself (or maybe you have your own special patches), here’s what you do:

Your lovely new ab binary is now waiting for you in the ‘support’ directory.

I do hope this helped you out, and would love to get a comment or two if it did πŸ™‚

Previous

Motorway service areas: what are they for?

Next

Support your local post office: don’t print your own postage!

5 Comments

  1. inw

    The search engines will love you all the more if you mention what platform your binary is for :).

  2. shahzaib.cb

    What if someone sending 1000 concurrent requests to our server by using ab tool just to make our server down ? How can i stop this attack ?

  3. TheGingerDog

    Thanks for the binary – just what this lazy man was after (seems to work fine on Debian Jessie)

  4. Jff Frm

    Thanks for the guide, I used this to port the patch to httpd 2.4.43 w/ ssl support
    https://github.com/j3ffrw/httpd/tree/cache_buster/2.4/alpine

Leave a Reply to inwCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress & Theme by Anders Norén