ab – Apache server performance testing tool

The ab command is a tool that is used to benchmark the performance of an Apache web server. It sends a specified number of requests to the server and measures the amount of time it takes for the server to respond. This tool is useful for testing the performance of a web server and identifying bottlenecks in the server’s configuration.

Overview

The ab command is used by running the following command in a terminal:

ab [options] [http[s]://]hostname[:port]/path

The options that can be used with this command are described in the next section. The hostname and path arguments are required, while the port argument is optional and defaults to port 80 for HTTP and port 443 for HTTPS.

Here is an example of how to use the ab command to test the performance of a web server:

ab -n 100 -c 10 http://example.com/

This command will send 100 requests to the http://example.com/ URL with a concurrency level of 10. The output of the command will include statistics about the requests, including the total number of requests, the total time taken, and the average time per request.

ab - Apache server performance testing tool

Options

The following table lists the available options for the ab command:

OptionDescription
-n requestsNumber of requests to perform
-c concurrencyNumber of multiple requests to make at a time
-t timelimitMaximum number of seconds to spend on benchmarking
-p postfileFile containing data to POST
-T content-typeContent-type header for POST data
-kUse HTTP KeepAlive feature
-H headerAdd header to request
-A user-agentUser-Agent header for request
-v verbosityHow much troubleshooting info to print
-wPrint results in HTML format
-s timeoutMaximum number of seconds to wait for a response
-SDo not display progress messages
-rDon’t exit on socket receive errors
-X proxy:portUse proxy server for request
-VPrint version number and exit
-hDisplay usage information

Troubleshooting tips

If the ab command is not working as expected, there are a few common issues to check:

  • Make sure that the server being tested is running and accessible from the machine running the ab command.
  • Check that the hostname and path arguments are correct and that the server is configured to serve requests at that URL.
  • If the command is taking a long time to complete, try reducing the number of requests or the concurrency level to see if that improves performance.
  • If the command is failing with errors, check the output for any error messages and try to diagnose the issue based on those messages.

Notes

  • The ab command is included with the Apache web server and does not need to be installed separately.
  • This command is not limited to testing Apache web servers and can be used to test any web server that supports HTTP or HTTPS requests.
  • The ab command can generate a large amount of network traffic, so use caution when running it against production servers.