At work I have been using ApacheBench to help bench mark performance. It is a fabulous tool. After upgrading my OS to Lion, ApacheBench (ab) fails to run. Here was my error:
Scott ~/src: ab -n 5000 -c 100 http://127.0.0.1:3000/ 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 127.0.0.1 (be patient) Send request failed! apr_socket_recv: Connection reset by peer (54)
Apparently there is a patch to fix it, here, but I could not get it to work. That and the post is in another language, that google did a sos-so job of translating. I had read somewhere that this was fixed in new version of apache, version 2.3.14 (download here), which is in beta. I didn’t need to (or want to) install all of Apache, just ApacheBench so I compiled the source and copied over the binary. Here are the steps:
Scott ~/Desktop: cp ./support/.libs/ab /usr/local/apache2/bin/ab ./configure --prefix=/usr/local/apache2 make make install which ab output --> /usr/sbin/ab cd /usr/local/apache2/bin/ cp ab /usr/sbin/ab sudo cp ab /usr/sbin/ab
Success! Back to normal, everything is working again.
You may want to check out similar tools as well, like siege and http_load. I like ab, it is simple and easy to use.
At one point though it had issues in some cases:
http://paul-m-jones.com/archives/413
http://paul-m-jones.com/archives/421
where it would return results that clearly were not correct.
At the time ( a few years ago ) I was able to reproduce the issues that Paul saw in specific cases, but not in others. I haven’t run these recently so I can’t say if this is still an issue.
Something to keep in mind if you start seeing results that go against the obvious.
Joseph Scott
August 23rd, 2011
Thanks for sharing man ,
Cheers
Eqbal
October 25th, 2011
Hi. I’m trying to follow the code snippet above.
The line the copies stuff “cp ./support/.libs/ab”… where did you get /support/libs/ab from?
Thanks
Indy
November 1st, 2011
Hi,
You have to download the httpd source first.
Here is an updated link: http://ftp.download-by.net/apache//httpd/httpd-2.3.15-beta.tar.bz2
Anders
November 21st, 2011
I was just bitten by this, too. I was all psyched about benching my new web app and felt very disappointed when `ab` returned the errors you mentioned. At first I thought it was my app, which would be really bad. But when I still got the same error after I had lowered the concurrency count to 1 and the max requests to 10, I knew something was either really amiss with my app server, OS X’s networking stack was boofed, or `ab` had problems. Thanks for reporting this so I didn’t have to go on a long, wild goose chase.
Michael Chang
December 21st, 2011
Thanks for posting.
Btw, we only have to build a new ab, so only have to make in support folder.
liwen
January 11th, 2012
The link to the file seems to be broken?
http://ftp.download-by.net/apache//httpd/httpd-2.3.15-beta.tar.bz2
sevosa
February 1st, 2012
@sevosa I took out an extra “/” in the url. I think that was causing the issue. Try it now.
Scott
February 1st, 2012
The version is now available in the apache archives:
http://archive.apache.org/dist/httpd/httpd-2.3.15-beta.tar.gz
Thomas
March 15th, 2012
After recompiled new Apache version, I had got error too.
Then I use option -r
ab -n1000 -c20 -r google.com/
tquang
June 22nd, 2012
The latest version (2.4.2) has another bug. A fix and a homebrew formula are available at http://simon.heimlicher.com/articles/2012/07/08/fix-apache-bench-ab-on-os-x-lion
Sam
July 10th, 2012
What is with people telling others to overwrite the binary in /usr/sbin? That’s a system folder – you can expect Apple to overwrite yours whenever there’s an update. If anything in OS X explicitly depends on that version of the binary, it breaks. It’s also just bad practice.
Install it to /usr/local/bin or, if you prefer, /opt/local/bin. Hell, ~/bin, if you want. Anywhere but system-level folders (/usr/bin, /usr/sbin, /sbin, /usr/libexec) is fine. Apple will leave it alone if it’s in one of those two. If the installed location is to the left of /usr/bin in your $PATH, then it’ll get called instead of the system one.
I thought you people were web developers. Learn your Unix filesystem hierarchy, and in the future, don’t teach anyone anything until you’ve learned the topic inside out.
lowell
October 15th, 2012