Stress test your web server with Apache Benchmark »
FERDY CHRISTANT - JUN 25, 2008 (06:53:07 AM)
Here's a little gem that I did now know about: the Apache Benchmark tool. This tool, called "ab", is included in pretty much every Apache installation. You run it from the command line. In the following example, I'm sending a 100 requests in total to my own site, 20 concurrently:
ab -n100 -c20 http://www.ferdychristant.com/
The results:
As you can see, there are various things returned, including latency times, document length, and most importantly how response times are distributed. A few remarks/tips apply to the usage of this tool:
- Use it with care. Do not put a huge load on public servers. Some may even detect it as an attack and block/report you.
- Use it from a local machine and enter a remote address. Using ab to check the performance of localhost is pointless
- Do not forget the trailing slash after the website address if you're opening a web root or folder
- There are various advanced options available, such as exporting the results to .CSV and automatic authentication for protected web sites.
- AB may not work for all websites. The reason is that it uses a non-standard user-agent value that is rejected by some sites. If the returned document length is very small, this is likely to be the problem.
- Somewhat of a general stress testing tip: distribute huge loads across clients. For example, even though you can tell ab to run 1000 requests concurrently, it does not make sense as local infrastructure is not likely to scale that much. Your own machine and the netwerk in between will be the bottleneck, not the server. In situations like this, all you can do is launch a coordinated load from different locations.
- The distribution of response times is crucial. Let's say you would have 99 fast responses, and one extremely slow. The total average could indicate that the server isn't really performing well, whilst in reality it is. As you can see from my example run, about 80% of the 100 request is served within about 2 seconds, whilst the last 20% takes a lot more time. We have likely hit a concurreny issue, not a speed issue.
- Finally, do not overrate concurrency. Apart from huge public websites, it is not likely that you will have hundreds of concurrent users in reality.


Comments: 2
Reviews: 1
Average rating:
Highest rating: 5
Lowest rating: 5
COMMENT: URS MELI
JUN 25, 2008 - 10:46:03 AM
COMMENT: JOSHUA
JUL 30, 2008 - 03:59:15 AM
Thks. «