Testing your site’s performance using ApacheBench

Ken Alex Fassone
Carwow Product, Design & Engineering
2 min readJul 24, 2015

The other day we had a huge slowdown on some pages of our website, and when I investigated the cause I re-discovered a great tool for troubleshooting page-load speeds.

The problem with investigating performance problems is that it’s hard to tell if a change have any effect. Sometimes a page might look faster or slower to load depending on caching, the number of requests, CPU load, and many other factors.

I needed a tool to simulate the load and return me a nicely formatted report. At this point I remembered about ApacheBench (ab).

I opened up my Ubuntu box and installed it. The installation is quite simple:

$ sudo apt-get update; sudo apt-get install apache2-utils;

After installing it I immediately tried to test the speed of my endpoint:

$ ab -n 100 -c1 -A admin:secret https://localhost:3000/api/test/page

Explanation:
-n <number> number of requests to generate

-c <number> number of threads to spawn

-A <login:password> basic http authentication

The end result is a nicely formatted report:

This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software: WEBrick/1.3.1
Server Hostname: localhost
Server Port: 3002
SSL/TLS Protocol: TLSv1.2,DHE-RSA-AES256-GCM-SHA384,2048,256

Document Path: /api/v2/makes/Volkswagen/models/Golf
Document Length: 5909 bytes

Concurrency Level: 1
Time taken for tests: 19.100 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 654500 bytes
HTML transferred: 590900 bytes
Requests per second: 5.24 [#/sec] (mean)
Time per request: 191.003 [ms] (mean)
Time per request: 191.003 [ms] (mean, across all concurrent requests)
Transfer rate: 33.46 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 5 7 1.7 6 11
Processing: 92 184 92.7 196 976
Waiting: 92 184 92.7 195 975
Total: 97 191 93.0 201 985

Percentage of the requests served within a certain time (ms)
50% 201
66% 210
75% 218
80% 220
90% 233
95% 250
98% 275
99% 985
100% 985 (longest request)

With such a powerful tool, fixing the issue was a piece of cake!

Originally published at underthehood.carwow.co.uk on July 24, 2015.

Interested in making an Impact? Join the carwow-team!
Feeling social? Connect with us on Twitter and LinkedIn :-)

--

--