How to Perform Load Testing Using Apache Benchmark (ab)
Introduction
Apache Benchmark (ab) is a simple command-line utility used to perform basic load and performance testing on web servers and websites. It sends multiple HTTP requests to a specified domain or IP address and measures the server’s response. It provides useful performance metrics such as response time, requests per second, failed requests, and transfer rate. Apache Benchmark is easy to install and use on Linux systems. This article explains how to install and perform basic load testing using the ab utility.
Prerequisites
- Ubuntu/Linux or macOS system
- Apache Benchmark (
ab) utility installed - Domain name or IP address of the target server
- Network connectivity to the target server
- Proper authorization to perform load testing
IMPLEMENTATION
There are multiple ways to perform load testing of web servers and websites. The most commonly used load testing tools are JMeter and ab benchmarking. We are going to explain how to perform ab benchmarking load testing on a website.
Assumption:
- We will perform ab benchmark testing on an Ubuntu host. We can perform the same testing on Mac or any linux flavour as well. We need to install the ab utility on the machine
- Domain name or IP address on which we want to perform load testing.
Performance Testing:
Let’s start with ab utility installation. Since this post deals with an Ubuntu host, use apt-get to install the ab utility.
apt-get -y install apache2-utils
The above command will install the ab utility on the host.
Now, execute the ab benchmark command to get the stats.
ab -n 100 -c 10 http://domain.tld
where,
n – Number of requests to perform for the benchmarking session. The default is to perform a single request, which usually leads to non-representative benchmarking results.
c- Number of multiple requests to perform at a time. To load a single webpage, normally the browser sends multiple requests to serve a single page. In our example, we assumed that 10 requests are being sent to load the page.
The sample output
Server Software: Apache
Server Hostname: domain.tld
Server Port: 80Document Path: /
Document Length: 51753 bytesConcurrency Level: 10
Time taken for tests: 26.274 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 5197900 bytes
HTML transferred: 5175300 bytes
Requests per second: 3.81 [#/sec] (mean)
Time per request: 2627.362 [ms] (mean)
Time per request: 262.736 [ms] (mean, across all concurrent requests)
Transfer rate: 193.20 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 271 305 35.7 293 482
Processing: 1760 2177 430.1 2063 5716
Waiting: 561 828 78.1 821 1242
Total: 2061 2482 429.0 2370 6016Percentage of the requests served within a certain time (ms)
50% 2370
66% 2458
75% 2542
80% 2584
90% 2780
95% 3021
98% 3605
99% 6016
100% 6016
From the above example, we can see that the concurrency level is 10, which means that at a time, we are sending 10 concurrent connections.
The time taken for tests gives the output on how long the benchmark utility takes to complete the test.
Conclusion
Apache Benchmark (ab) is a simple and effective utility for performing basic load testing of web servers and websites. It provides useful information about server response time, concurrent requests, throughput, and failed requests. These results can help administrators understand the performance of a web server under a specific load. However, ab is mainly suitable for basic HTTP benchmarking and may not cover complex application scenarios. For advanced load and performance testing, tools such as Apache JMeter can be used.
