ab) is a command line application for bench marking your web application. It was originally developed to test the Apache HTTP server but it is not limited to it — you can use the tool to test any web server.
ab) is bundled in the
You can install it on Debian/Ubuntu platforms with
apt-get install -y apache2-utils.
If you're on a macOS powered system,
ab is already installed, because macOS ships with Apache HTTP server.
Suppose we want to see how fast
example.com can handle 100 requests (
-n 100), with a maximum of 10 requests (
-c 10) running concurrently.
ab -n 100 -c 10 https://example.com/
ab) will then generate the following output:
Server Software: ECS Server Hostname: example.com Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128 Server Temp Key: ECDH P-256 256 bits TLS Server Name: example.com Document Path: / Document Length: 1256 bytes Concurrency Level: 10 Time taken for tests: 4.990 seconds Complete requests: 100 Failed requests: 0 Total transferred: 160293 bytes HTML transferred: 125600 bytes Requests per second: 20.04 [#/sec] (mean) Time per request: 499.031 [ms] (mean) Time per request: 49.903 [ms] (mean, across all concurrent requests) Transfer rate: 31.37 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 309 339 18.4 338 383 Processing: 100 108 6.3 106 129 Waiting: 99 106 6.2 104 124 Total: 410 447 22.1 446 511 Percentage of the requests served within a certain time (ms) 50% 446 66% 453 75% 459 80% 463 90% 479 95% 488 98% 505 99% 511 100% 511 (longest request)
You can get some really useful information from it.
Complete requests: 100 Failed requests: 0
These two lines tell us, that not a single request failed. Which in fact means, that your setup is capable of serving this amount of requests.
Requests per second: 20.04 [#/sec] (mean) Time per request: 499.031 [ms] (mean) Time per request: 49.903 [ms] (mean, across all concurrent requests)
This part gives us information on the number of requests per second your application was able to fulfil.
Requests per second gives you an idea of how well your web application is performing. The larger the number, the better the performance.
Time per request (mean) tells you the average amount of time it took for a concurrent group of requests to process (so in our case 10 requests took 499.031ms).
Time per request (mean, across all concurrent requests) tells you the average amount of time it took for a single request to process.
Connection Times (ms) min mean[+/-sd] median max Connect: 309 339 18.4 338 383 Processing: 100 108 6.3 106 129 Waiting: 99 106 6.2 104 124 Total: 410 447 22.1 446 511
These figures show you the component breakdown of each request.
Connect gives you information about the time it took to establish connection with your server (which is most typically the network latency).
The Processing time is the total amount of time the web application took to process and send a complete response.
Waiting is the time-to-first-byte after the request was sent.
Alternatives to ApacheBench (ab)
Apache JMeter: Apache JMeter is a Java based application for analyzing and measuring the performance of web applications. As opposed to ApacheBench, JMeter has a GUI to create load test scenarios. JMeter supports variable parameterization, assertions (response validation), plugins, configuration variables and report generation. Apart from the outdated GUI, JMeter is in any case a very good (and free) tool for creating complex load test scenarios.
loadtest: loadtest is an easy to use, Node.js based alternative to ApacheBench (ab).
weighttp: weighttp is a lightweight and small benchmarking tool for web servers. I've never used it, though.
artillery: Artillery is a Node.js based load-testing toolkit. Artillery allows you to test HTTP, Socket.io, WebSockets, and AWS Kinesis. You can also emulate complex user behaviour. There is also a paid version to run distributed load tests. Unfortunately I cannot give you any further information or insights, because I did not used Artillery yet.
I hope you find this article useful and you give ApacheBench (ab) a try.
In my opinion it is a great tool for quickly load testing your web application. If you know how to use it, you get useful results and metrics on how your web application performs.
If you like my content, you might want to follow me on Twitter?! @fullstack_to
Top comments (3)
I very much recommend writing your own ab as a programming excercise. I did and had a lot of fun: github.com/katafrakt/locust
I couldn't find out, how ApacheBench can be installed on Windows. If anyone knows, please share and I will update my article.
I haven't used Windows in ages but as far as I remember, it comes as a binary in ZIP file with Apache server files, which you can download for example here: apachelounge.com/download/