Last Updated on April 1, 2023 by Vikash Ekka
ab command, also known as Apache Bench, is a popular tool for testing the performance of web servers. It allows you to simulate high levels of traffic to a server and measure its response time, throughput, and other performance metrics.
The syntax of the
ab command is as follows:
ab [options] [http[s]://]hostname[:port]/path
The options available for
-n: The number of requests to send to the server. For example,
-n 100would send 100 requests.
-c: The number of requests to send concurrently. For example,
-c 10would send 10 requests at a time.
-t: The amount of time to run the test in seconds. For example,
-t 60would run the test for 60 seconds.
-k: Use HTTP keep-alive feature for requests.
There are several other options available for
ab, which you can find in the
ab manual page.
How to Use Apache bench for Load Testing
ab, you first need to have it installed on your system. On Linux systems, you can install it using your package manager.
For more details you can check official Apache page
For example, on Ubuntu, you can install it by running the following command:
sudo apt-get install apache2-utils
ab is installed, you can use it to test the performance of a web server.
Run Apache bench load testing
To test the performance of a web server at
http://example.com/, you can run the following command:
ab -n 1000 -c 50 http://example.com/
This will send 1000 requests to
http://example.com/ with 50 requests being sent concurrently. The output of the command will show the response time and other performance metrics for each request, as well as an overall summary of the test.
It’s important to note that the results of a
ab test may not accurately reflect the performance of a web server under normal conditions.
ab simulates a high volume of traffic to the server, which may not reflect the behavior of real users. Additionally, the results may be affected by factors such as network latency and server load.
How to Hide Apache, Nginx, or PHP version on Ubuntu
How To Install phpMyAdmin on Ubuntu 22.04 with Apache
How to Uninstall PHP, Apache and MySQL on Ubuntu 20.04 LTS
This output shows the results of a load testing command run using ApacheBench (ab). The command was used to test the performance of a website located at https://www.vetechno.in.
[email protected]:~$ ab -n 10000 -c 550 https://vetechno.in/ This is ApacheBench, Version 2.3 <$Revision: 1879490 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking vetechno.in (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: Apache Server Hostname: vetechno.in Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128 Server Temp Key: ECDH P-256 256 bits TLS Server Name: vetechno.in Document Path: / Document Length: 8053 bytes Concurrency Level: 550 Time taken for tests: 133.840 seconds Complete requests: 10000 Failed requests: 1263 (Connect: 0, Receive: 0, Length: 1263, Exceptions: 0) Non-2xx responses: 1263 Total transferred: 79945776 bytes HTML transferred: 70525777 bytes Requests per second: 74.72 [#/sec] (mean) Time per request: 7361.216 [ms] (mean) Time per request: 13.384 [ms] (mean, across all concurrent requests) Transfer rate: 583.32 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 628 904 537.2 774 5620 Processing: 260 5984 12539.6 2293 78755 Waiting: 259 5979 12539.5 2293 78751 Total: 941 6888 12698.6 3116 82343 Percentage of the requests served within a certain time (ms) 50% 3116 66% 5059 75% 6897 80% 10210 90% 11084 95% 15876 98% 72973 99% 76207 100% 82343 (longest request)
The test was performed by making 10,000 requests with a concurrency level of 550 (meaning 550 requests were sent simultaneously), and the results indicate that the test took 133.84 seconds to complete, with an average of 74.72 requests per second. However, there were 1,263 failed requests with non-2xx responses. The output also provides additional details on server software, hostname, port, SSL/TLS protocol, document path and length, and connection times, including the minimum, mean, median, maximum, and standard deviation. Finally, the percentage of requests served within certain time intervals is shown, ranging from 50% to 100%, with the longest request taking 82,343 milliseconds.
ab command is a useful tool for testing the performance of web servers. It allows you to simulate high levels of traffic and measure response time, throughput, and other performance metrics. However, it should be used with caution and in conjunction with other testing tools to get a more accurate picture of server performance.