Back to articles
Technology Insight

Scaling Performance Metrics: How to Build a Distributed Load Testing Infrastructure Using Locust on Budget VPS Clusters

May 26, 2026

Introduction to High-Concurrency Load Testing

In modern software engineering, ensuring application stability under high user traffic is a critical milestone before any major production deployment. Traditional single-instance load testing often hits a physical hardware bottleneck long before the target application is fully stressed. When your testing tool exhausts its local CPU or network bandwidth, it produces inaccurate metrics, leaving your infrastructure vulnerable to real-world outages.

To overcome these limits without incurring the massive costs of premium managed testing platforms, engineering teams are increasingly turning to Distributed Load Testing. By spreading the traffic generation load across a cluster of virtual private servers (VPS), you can simulate thousands of concurrent users seamlessly. This guide provides an actionable, step-by-step framework to architect, configure, and execute a distributed load testing infrastructure using Locust on a cluster of three budget-friendly VPS instances.

Why Choose Locust for Distributed Performance Testing?

While legacy tools like Apache JMeter have dominated the industry for years, Locust offers a modern, code-first alternative that aligns perfectly with DevOps practices. Here is why Locust is uniquely suited for distributed environments:

  • Python-Based Test Scripts: Tests are written in pure Python, eliminating the need to manage massive, unreadable XML configuration files. This allows for dynamic user behavior modeling and native integration with version control systems.
  • Asynchronous Event Loop: Locust utilizes gevent, an asynchronous, coroutine-based Python networking library. This architecture allows a single Locust process to handle thousands of concurrent users efficiently, maximizing the utility of low-spec VPS hardware.
  • Native Master-Worker Architecture: Setting up a distributed cluster does not require complex third-party plugins. Locust inherently supports a master-worker configuration out of the box, making scaling a matter of launching a single command line argument across your nodes.

Architecting the 3-Node Budget VPS Cluster

For this deployment, we utilize three budget VPS instances running a stable Linux distribution such as Ubuntu 24.04 LTS. Budget VPS providers (e.g., DigitalOcean, Linode, or Hetzner) offer highly cost-effective compute power perfect for horizontal scaling. Our architecture is divided as follows:

  1. Node 1: The Master Node (1 vCPU, 2GB RAM) – This node acts as the orchestrator. It hosts the web user interface, aggregates real-time metrics sent by worker nodes, and coordinates test execution. The master node does not generate traffic itself, meaning it requires minimal CPU but benefits from adequate RAM to manage state and metrics.
  2. Node 2: Worker Node A (1 vCPU, 2GB RAM) – Dedicated to traffic generation. It executes the Python test scripts and sends performance telemetry back to the Master.
  3. Node 3: Worker Node B (1 vCPU, 2GB RAM) – Operates identically to Worker Node A, doubling your total concurrent user capacity.
Note on Networking: To guarantee low latency and avoid public bandwidth charges, it is highly recommended to configure these instances within a Private VPC network. If a private network is unavailable, ensure your firewall rules strictly restrict communication between nodes via their public IP addresses.

Step 1: System Optimization and Environment Preparation

Before installing Locust, the underlying operating system on all three nodes must be optimized to handle a high volume of concurrent network connections. By default, Linux limits the number of open file descriptors, which will cause your test to fail with "Too many open files" errors under high load.

Updating File Limits

Execute the following commands on all three nodes to increase the system limits:

sudo bash -c 'cat <> /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
EOT'

Apply these changes immediately by running sysctl -p or rebooting the instances.

Installing Python and Dependencies

Next, install Python, the package manager pip, and the required building tools on all nodes:

sudo apt update && sudo apt install -y python3-pip python3-venv build-essential

Step 2: Designing a Scalable Locust Test Script

Create a test script named locustfile.py. This file must reside on all nodes (or be placed in a shared directory) so both the master and workers understand the test logic. Below is a professional, production-ready script that simulates realistic user workflows, including pacing and stateful requests:

import time
from locust import HttpUser, task, between, tag

class ECommerceUser(HttpUser):
    # Simulate a realistic delay between tasks (1 to 5 seconds)
    wait_time = between(1, 5)

    @tag('browse')
    @task(3)
    def view_products(self):
        """Simulates a user browsing product catalogs."""
        self.client.get("/api/v1/products", name="/products")

    @tag('checkout')
    @task(1)
    def proceed_to_checkout(self):
        """Simulates an authenticated user adding an item and checking out."""
        # Scenario requires headers
        headers = {"Authorization": "Bearer mock-token-12345"}
        payload = {"product_id": 42, "quantity": 1}
        
        with self.client.post("/api/v1/cart", json=payload, headers=headers, catch_response=True) as response:
            if response.status_code == 201:
                response.success()
            else:
                response.failure(f"Unexpected status code: {response.status_code}")

Step 3: Setting Up and Orchestrating the Distributed Cluster

1. Configuring and Starting the Master Node

Log into your Master Node (Node 1). Ensure that port 8089 (for the Web UI) and port 5557 (for communication between the master and worker nodes) are open in your cloud firewall. Start the master instance by executing:

locust -f locustfile.py --master

The terminal will output log entries indicating that the master process is running and actively listening for worker connections on port 5557.

2. Initializing the Worker Nodes

Log into both Worker Node A and Worker Node B. Run the following command, replacing with the internal network IP address of your Master Node:

locust -f locustfile.py --worker --master-host=

Upon execution, check the logs on the Master Node. You should see validation messages confirming that two worker nodes have successfully registered and established a handshake protocol.

Step 4: Executing Tests and Analyzing Metrics via the UI

With the cluster fully assembled, open your preferred web browser and navigate to http://:8089. You will be greeted by the native Locust dashboard.

The interface will display 2 Workers Connected in the top right status bar. You can now configure your target run parameters:

  • Number of Users: Enter the peak concurrent user count (e.g., 5000 users).
  • Ramp-Up Rate: Define how many users spawn per second (e.g., 50 users/sec) to avoid overwhelming your target system instantaneously.
  • Host: Enter the base URL of the target infrastructure you are testing (e.g., [https://staging-api.yourcompany.com](https://staging-api.yourcompany.com)).

Click Start Swarm. As the test runs, the Master aggregates performance data from all workers in real time. Pay close attention to the Failures/s and the 95% percentile response time charts to identify where infrastructure bottlenecks begin to surface.

Best Practices for High-Scale Load Generation

When executing mass concurrency on affordable infrastructure, adhering to operational best practices prevents your test environment from skewing results:

  • Disable Local Logging Under High Load: Disk I/O operations can slow down your workers. Run Locust with the --loglevel ERROR flag during large-scale tests.
  • Monitor Worker CPU Utilization: If any worker node reaches 100% CPU usage, the response times reported will include local processing delays. If this occurs, scale horizontally by introducing a fourth or fifth cheap VPS node.
  • Never Load Test Production Without Authorization: Ensure all targets are located within isolated staging environments, and verify that upstream network providers are notified to prevent your traffic from being classified as a Distributed Denial of Service (DDoS) attack.

Conclusion

Building a distributed load testing cluster does not require an enterprise cloud budget. By combining the asynchronous efficiency of Locust with an organized cluster of cheap Linux VPS instances, you can generate significant application load at a minimal cost. This framework empowers engineering teams to validate application performance continuously, ensuring scalability remains predictable and verifiable before every major release.

Scaling Performance Metrics: How to Build a Distributed Load Testing Infrastructure Using Locust on Budget VPS Clusters | DPTCloud