Installing Apache Bench on CentOS for Website Stress Testing

Publish: 2018-03-29 | Modify: 2018-04-21

ApacheBench (ab for short) is a command-line program used for website stress testing. If Apache is already installed, the ab tool will come with it. If you don't want to install Apache but still want to use the ab command, you can install ApacheBench separately using the following method.

ApacheBench

Installation

# Install the necessary dependencies
yum -y install apr-util
yum -y install yum-utils
# Create a temporary directory
mkdir abtmp && cd abtmp
# Install ApacheBench
yumdownloader httpd-tools*
rpm2cpio httpd-tools-*.rpm |cpio -idmv
# Copy the ab executable
cp usr/bin/ab /usr/bin

Enter the above commands, one line at a time. If everything goes well, you can use ab -V to check the relevant information, as shown in the screenshot below.

ab version

Website Stress Testing

Enter the command ab -n 1000 -c 50 https://www.baidu.com/ to perform the test. This command means sending 1000 requests to www.baidu.com with a concurrency level of 50. The two most commonly used parameters are:

  • -n: Specifies the number of requests to perform in the test session.
  • -c: Specifies the number of multiple requests to make at a time.

For more parameter explanations, please visit the ab command page.

By analyzing the logs, it was found that the ab command had sent a large number of requests, as shown in the screenshot below. It is equivalent to a small-scale CC attack on the website.

CC attack

Conclusion

ApacheBench can be used for website stress testing and can also be used to launch CC attacks. Please use it responsibly.

This article references some content from Installing ab command separately in CentOS. For defense against CC attacks, you can refer to CentOS 7 installation of fail2ban + Firewalld to prevent brute force and CC attacks.


Comments