Operations 6 min read

Using ApacheBench (ab) for Load Testing of a Load‑Balancing Module in the Qiyun Project

This article explains how to employ the open‑source ApacheBench (ab) tool to conduct load‑testing and dynamic monitoring of a Linux‑based load‑balancing module, detailing environment setup, command parameters, and result analysis for effective performance evaluation.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Using ApacheBench (ab) for Load Testing of a Load‑Balancing Module in the Qiyun Project

Load testing is a frequent requirement for testers, and while many commercial tools exist, open‑source utilities like ApacheBench (ab) can be sufficient for many scenarios. The author shares practical experience using ab to test a load‑balancing module in the Qiyun project.

Case Background : Load balancing (LB) distributes network traffic across multiple servers to improve capacity and availability. The Qiyun platform includes such a module, and the author needed a simple way to verify its behavior and monitor it dynamically.

ab Overview : ab is the Apache Bench command, a lightweight HTTP performance testing tool that measures how many requests per second a server can handle. It creates multiple concurrent threads to simulate many users, works against any HTTP server (Apache, Nginx, Tomcat, IIS, etc.), and has low resource consumption on the client side.

Advantages of ab : Minimal CPU and memory usage on the client, yet capable of generating significant load on the target server, similar to a DoS attack, so testers must use it responsibly.

Test Environment Setup : Two cloud VMs act as Nginx servers (server1 and server2). A third VM installs ab and serves as the load‑testing client. The Nginx configuration file /etc/nginx/conf.d/default.conf is modified to define the load‑balancing rules.

Testing Goals : (1) Verify that the load balancer actually distributes requests between the two servers. (2) Observe real‑time status changes of the load balancer, which is difficult without a pressure‑testing tool.

Testing Steps :

1. Execute ab on the client, for example:

ab -c1000 -n1000 http://X.X.X.X:100/index.php

Parameters: -n specifies total number of requests; -c defines concurrent requests. Adding -k enables keep‑alive (persistent) connections.

2. Increase the open‑files limit on the Nginx servers (default 1024) using ulimit -n to avoid socket exhaustion.

3. Clear Nginx access logs ( echo " " > /var/log/nginx/access.log ) and later inspect them ( cat /var/log/nginx/access.log ) to confirm that requests are being distributed to both servers.

4. View the load‑balancing monitoring chart to visually confirm the effect of the concurrent requests.

The article includes several screenshots illustrating the load‑balancing architecture, Nginx configuration, test steps, and monitoring results.

In conclusion, the author demonstrates that a simple, free tool like ab can effectively perform load testing and dynamic monitoring of a load‑balancing setup, provided that testers manage client resource usage and server limits carefully.

Load BalancingPerformance TestingLinuxload testingab commandApacheBench
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.