How to Install Apache Bench on CentOS for Website Stress Testing

apache benchcentos ab installationwebsite stress testingab command tutorialcc attack simulation
Published·Modified·

Apache Bench (abbreviated as ab) is a command-line tool used for website stress testing. If Apache is already installed, the ab tool comes bundled with it. If you want to use the ab command without installing Apache, you can install Apache Bench separately using the following method.

Apache Bench

Installation

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

Enter the commands above one by one. If there are no unexpected issues, you can enter ab -V to view the relevant information, as shown in the screenshot below.

Ab Version Info

Website Stress Testing

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

  • -n: Specifies the number of requests to use for the test session.
  • -c: Specifies the number of requests to send to the server at one time.

For more parameter descriptions, please visit: ab command.

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

Log Analysis

Summary

Apache Bench can be used for website stress testing, but it can also be used to launch CC attacks. Please do not abuse it.

Some content of this article refers to: Install ab command separately under CentOS For CC attack defense solutions, please refer to: CentOS 7 Install fail2ban + Firewalld to Prevent Brute Force and CC Attacks