The popular web server benchmark tool Apache Bench, better known as
ab, comes built in with the Apache
httpd web server of OS X, but it has serious issues with the latest relaese, OS X Lion. To add insult to injury, the official release has another bug that manifests itself fatally on OS X Lion. This latter bug is related to a feature that was added recently and it breaks
ab on IPv6-capable hosts. Even if you have never heard of
IPv6, OS X Lion has IPv6 built in.
The latest development version of Apache (Subversion trunk) has a fix for this bug, however this fix is not yet available in a regular release.
This is a short tutorial on how to compile
ab in OS X Lion
ab of OS X Lion has a bug that manifests itself by socket errors from the Apache Portable Runtime
APR, such as
apr_socket_recv: Connection reset by peer (54):
1 2 3 4 5 6 7 8 9
Apparently, the same issue has also been observed on FreeBSD. The patch mentioned in this post has been merged into
ab after the revision that ships with OS X Lion.
Latest Stable Release of
The latest stable version has a different bug. Ironically, you can read about the patch that introduces the bug in the official bug tracker.
Compiling the Subversion Trunk
Since the Subversion trunk does not come with a
configure script, it is easier to download the latest stable release,
httpd-2.4.2, and then patch the source code of
This formula also should appear in the
homebrew-dupes tap soon.
httpd web server requires the
PCRE library for regular expression parsing,
ab does not use this. In other guides on how to compile
ab, it is assumed that you have Homebrew and you are asked to install
PCRE. However, this is simply a waste of time and disk space because
PCRE will only be considered during the
It makes much more sense to simply remove the requirement for
APR from the
configure script. This is what is done in the above Homebrew formula.
How this can be accomplished without Homebrew is given in the following
zsh shell script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
Download the script, make it executable, and run it. It will ask you for your password in order to be able to install to
/usr/local. If you would like to change the target directory, simply edit the definition of the
After the installation, you might have to rehash the path of your shell:
1 2 3 4 5
ab -V to check that the new version works:
1 2 3 4