ApacheBench - Technological watch

Learn what is ApacheBench in less than 5 minutes !
Monday, October 30, 2023

Problematic

When it comes to web server performance, ensuring your Apache HTTP server is running at its peak is crucial. But how can you measure its performance, and why was the ab tool created in the first place? In this blog post, let’s take a look at benchmarking Apache.

About the ab Tool

ab, short for Apache Benchmark, is a versatile utility designed for precisely that purpose. It empowers web administrators and developers to assess the performance of their Apache HTTP servers efficiently. By simulating real-world traffic, ab helps you gauge how well your Apache installation is handling various loads and requests per second.

ab is a utility that allows you to test the performance of your Apache HTTP server. It is designed to give you an idea of how well your Apache installation is performing. In particular, it allows you to determine the number of requests that your Apache installation is capable of serving per second.

Installation

Before we explore the capabilities of the ab tool, let’s ensure you have it installed on your system. Depending on your Linux distribution, you can install it with these commands:

  • Debian - apt-get install apache2-utils
  • Ubuntu - apt-get install apache2-utils
  • Alpine - apk add apache2-utils
  • Arch Linux - pacman -S apache
  • Kali Linux - apt-get install apache2-utils
  • CentOS - yum install httpd-tools
  • Fedora - dnf install httpd-tools
  • Raspbian - apt-get install apache2-utils

Key Commands for Apache Benchmarking

Here are some essential ab commands you’ll find invaluable for benchmarking your Apache server:

  1. Execute 100 HTTP GET requests to a given URL:
Terminal window
ab -n 100 url
  1. Execute 100 HTTP GET requests, in concurrent batches of 10, to a URL:
Terminal window
ab -n 100 -c 10 url
  1. Execute 100 HTTP POST requests to a URL, using a JSON payload from a file:
Terminal window
ab -n 100 -T application/json -p path/to/file.json url
  1. Use HTTP [K]eep Alive, i.e. perform multiple requests within one HTTP session:
Terminal window
ab -k url
  1. Set the maximum number of seconds to spend for benchmarking:
Terminal window
ab -t 60 url

These commands will enable you to perform various tests and gather critical data about your server’s performance.

More Information

For in-depth information and additional options, you can refer to the official Apache documentation on ab.

Benchmarking your Apache server with ab is a crucial step in optimizing your web infrastructure. It allows you to identify bottlenecks, plan for scalability, and deliver the best possible web experience to your users.

In the next sections of this blog, we’ll explore how to use these ab commands effectively and interpret the results to enhance your Apache server’s performance. Stay tuned for more insights into Apache benchmarking!


Recommended articles