ApacheBench (ab), perform load tests of your web page

about Apache Bench

In the next article we are going to take a look at ApacheBench (ab). This is a command line program. With which we can measure the performance of HTTP web servers. It was originally designed to test the Apache HTTP Server, but it turned out to be generic enough to test any web server.

The tool ab is included with the standard Apache source distribution. Like the Apache web server itself, it is free and open source software that is distributed under the terms of the Apache License.

Either as one of the steps during design, prior to going to production or any other scenario, it is usual to need to measurements on the number of pages that our web server will be able to serve. This type of tests, also known as stress tests or stress tests, are especially useful when sizing our servers.

ApacheBench (ab) is a load testing and benchmarking tool for the Hypertext Transfer Protocol (HTTP) server. It can be run from the command line and is very easy to use. We will be able to get a test start in just one minute. Since you don't need a lot of familiarity with the concepts of load and performance, it is suitable for beginners and intermediate users. To use this tool, no complex setup is required.

ApacheBench General Features

Here are some of the most important features and limitations of ApacheBench:

  • Being an open source software, it is available for free.
  • It is a program that we can use from the command line in a simple way.
  • It is a tool regardless of the platform we use. This means that we will be able to use it equally in Gnu / Linux or in Windows servers.
  • The program can perform load and performance tests for web server only: HTTP or HTTPS.
  • It is not extensible. The program is what it is, nothing more.
  • ApacheBench uses only one operating system thread regardless of concurrency level (specified by -c option). Therefore, when comparing high-capacity servers, a single ApacheBench instance can be a bottleneck. To fully saturate the target URL, it is best to use additional ApacheBench instances in parallel, if your server has multiple processor cores.

Install ab

Check if you have the "ab" tool installed on your system, by default it is not usual for it to come installed. If the system is Ubuntu or based on it, you can install it by typing in a terminal (Ctrl + Alt + T) the following command:

ApacheBench installation

sudo apt install apache2-utils

Launch a test with ApacheBench

Once the installation is complete, we are going to run a simple test. We want to know the behavior of our page when there are 100 requests with 10 users that connect at the same time. To perform this test, we write in the terminal (Ctrl + Alt + T):

ab -c 10 -n 100 https://www.ubunlog.com/

We indicate with "-c" the number of concurrent connections What we want. With "-n" we are going to indicate the total number of requests that we will do in this test.

ApacheBench running

It should be noted that Apache Bench can be somewhat dangerous when testing our website. We can provoke a denial of service if we make too many requests at the same time. It is advisable to carry out several tests, starting with some not very demanding and from there work your way up while you monitor the server.

commands available for apachebench

The test result is very interesting. It will provide us with the necessary data to make a good report on the load of our website. If we need a little more of the program, we can choose consult the help that the program will offer us from the terminal. This will show us the available options. We can also use the apache website.

Uninstall ApacheBench

If we have chosen to install ab individually, and we see that it does not convince us, we will be able to get rid of it by typing in the terminal (Ctrl + Alt + T):

sudo apt purge apache2-utils && sudo apt autoremove

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.