- Apache Ab Test
- Apache Ab Download
- Apache Ab Performance Testing
- Apache Ab Install
- Apache Ab Testing
- Apache Bench Ab
- Apache Ab Load Testing
Apache Bench or ab for short, is a command-line tool to perform simple load tests on an HTTP server, be it a website or an API.
By running the following command, you will get an overview of how the server is performing under load:
So, in this post, I will try to explain how we can use Apache Bench. I will start with how to install it, then proceed on how to use it and the available options, and finally, I explain how to interpret the results.
Apache Bench or ab for short, is a command-line tool to perform simple load tests on an HTTP server, be it a website or an API. By running the following command, you will get an overview of how the server is performing under load: ab -n 100 -c 10 So, in this post, I will try to explain how we can use Apache Bench. Apache Bench (ab) is a load testing and benchmarking tool for Hypertext Transfer Protocol (HTTP) server. It can be run from command line and it is very simple to use. A quick load testing output can be obtained in just one minute.
Apache Ab Test
Let’s get started!
Installation
One of the advantages of Apache Bench is that you may already have ab
installed, depending on the OS you are using. For macOS users, it comes pre-installed by default, and if you are using a Linux Distribution, there are a lot of chances that it is also installed as it comes with the httpd
package. Try to run ab -help
to verify if that’s the case.
![Apache ab download Apache ab download](https://clouddocs.f5.com/training/community/sp/html/_images/tcp_3_way2.png)
In case it is not installed, you will need to install the apache2-utils
package. For example, if you are using Ubuntu
you will have to run:
So, now, that we have Apache Bench installed, let’s see how we can use it and some of the available options.
Usage
The simplest possible way to use Apache Bench is by running ab <url>
. This command will perform a single network request, but this is not exactly what we would call “load”. For this reason, Apache Bench comes with a plethora of options you can use to define more complex use cases.
Some of the most useful ones are the following:
-n
: Number of requests-c
: Number of concurrent requests-H
: Add header—r
: flag to not exit on socket receive errors-k
: Use HTTP KeepAlive feature-p
: File containing data to POST-T
: Content-type header to use for POST/PUT data,
Now you can use those options like so:
Please note that you need the trailing /
on the URL, or else you will get the error message ab: invalid URL
.
If you want to perform a benchmark test for a POST request, you can run the following command:
TIP: For a full list of options, you can run ab -help
, refer the man page by running man ab
, or visit the documentation online.
Let’s now see how the output would look like and how to interpret it!
Response interpretation
Apache Ab Download
Once ab
completes the HTTP requests, it will generate an output that will look like the following snippet:
In this first section, you can find some useful information like, for example, that the number of Complete requests
was 1000 and the Concurrency Level
was 10. Furthermore, you can see that it performed 1264.17 Requests per second
.
In the Connection Times
section, you can see that the fastest request took 3 ms (Total
row and min
column), the slowest took 111 ms (Total
row and max
column), while the mean was 7 ms (Total
row & mean
column).
In the last section, you get an overview of the response times in a cumulative distribution. In this example, we can see that 95% of requests took 8 ms or less to complete and that total response times of more than 100 ms is an outlier as it covers less than 1% of the sample.
Apache Ab Performance Testing
Conclusion
And that’s about for this intro on Apache Bench! By now, you should be able to use the ab
command to perform load tests on an HTTP server and get some insights from the results.
In the end, I would say that Apache Bench is an ideal solution if you want to perform a quick load test since it is probably already installed on your machine and it is really simple to use. In case you want to cover more advanced use cases like flows and random URL entries, then I think that there are other more modern and feature-complete tools. A few examples are JMeter, K6 and Gatling.
Apache Ab Install
Thanks for reading, I hope that you find this post useful, and if you have any questions or comments about this post, feel free to reach out to me on Twitter!
Apache Ab Testing
Until next time!
- Apache Bench Tutorial
- Apache Bench Useful Resources
Apache Bench Ab
- Selected Reading
Apache Bench (ab) is a load testing and benchmarking tool for Hypertext Transfer Protocol (HTTP) server. It can be run from command line and it is very simple to use. A quick load testing output can be obtained in just one minute. As it does not need too much familiarity with load and performance testing concepts, therefore it is suitable for beginners and intermediate users. To use this tool, no complex setup is required. Moreover, it gets installed automatically with Apache web server, or it can be installed separately as Apache utility. It does not have all the features of more popular tools such as jMeter or Grinder, but it is good for a start.
This tutorial is designed for Application Developers and System Administrators, who are willing to learn Apache Bench in simple and easy steps. This tutorial will give you practical knowledge on Apache Bench, and after completing this tutorial, you will be at an intermediate level of expertise from where you can take yourself to higher level of expertise.
Apache Ab Load Testing
Before proceeding with this tutorial, you should have a basic understanding of command line interface (CLI), HTTP, text editor and web servers, etc., because you will need these tools to successfully run Apache Bench for load testing. In addition, it will be good if you have knowledge of web development and application testing processes.
![](https://cdn-ak.f.st-hatena.com/images/fotolife/r/ruriatunifoefec/20200910/20200910011324.png)