Post Date: March 9, 2017
Last Updated: September 30, 2026
Introduction
Web server and website performance can be evaluated using various load-testing and benchmarking tools. ApacheBench (ab) is a simple command-line utility that can be used to perform basic load and performance testing on a website or web server. It allows you to send multiple HTTP requests concurrently and provides useful statistics such as response time, requests per second, transfer rate, and connection times.
In this post, we will explain how to install ApacheBench on an Ubuntu system and use it to perform a basic load test against a website.
Prerequisites
Before performing the ApacheBench load test, ensure that the following requirements are met:
- An Ubuntu server or system with access to the command line. The same procedure can also be adapted for other Linux distributions or macOS.
- Sufficient privileges, such as
sudoor root access, to install the ApacheBench utility. - The
apache2-utilspackage installed on the system, which provides theabutility. - A valid domain name or IP address of the website or web server that you want to test.
- Authorization to perform load testing against the target website or server, especially when testing a third-party or production environment.
Implementation
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 just 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
ApacheBench (ab) provides a simple way to perform basic load and performance testing of a website or web server from the command line. By specifying the total number of requests and the concurrency level, you can measure important performance metrics such as response time, requests per second, and transfer rate.
The results can help identify basic performance characteristics and potential bottlenecks under concurrent requests. For more advanced load-testing scenarios, tools such as JMeter or other specialized performance-testing solutions may be more appropriate.
FAQs
1. What is ApacheBench (ab)?
ApacheBench (ab) is a command-line benchmarking tool used to perform basic load and performance testing of web servers and websites. It can send multiple HTTP requests and provide statistics about server performance.
2. How do I install ApacheBench on Ubuntu?
You can install ApacheBench using the following command:
apt-get -y install apache2-utils
The apache2-utils package includes the ab utility.
3. What does the -n option mean in ApacheBench?
The -n option specifies the total number of requests that ApacheBench should send during the test. For example, -n 100 sends 100 requests.
Talk to our experts
Looking for the right technology solution for your business?. Our experts can help with web hosting, domain registration, DevOps and cloud, software development, web applications, mobile applications, and enterprise solutions. Get in touch with our team here.