Guides

Load Testing HAProxy

How to run a performance test on the haproxy load balancer using LoadForge, stress test your HAProxy.

Load testing HAProxy (or other load balancers) with LoadForge is relatively simply, but does require a high performance backend to serve the content through the load balancer.

We have typically found that a highly optimized Nginx server can return around 50,000-100,000 pages per second reliably, but that requires an extreme amount of optimization. We won't cover that in this guide, but will be focusing on how to stress test the HAProxy installation. For more information on high performance web server configurations please see this guide.

Deciding what to test

HAProxy installations typically come in three types, each with decreasing performance as their complexity increases. These modes are:

  • Plain TCP load balancing (mode tcp)
  • HTTP load balancing (mode http)
  • SSL termination (mode http, with SSL)

On optimized systems we typically see up to 100,000 requests per second on TCP, up to 80,000 on HTTP and far less on SSL (10,000+). Be aware of the major change in performance depending on how CPU intensive your configuration is on your HAProxy server(s).

Creating a test

To test the load balancer you want your webservers to respond as fast as possible and have as little load as possible. We advise 2-3 optimized Nginx systems that are returning a static text file. You can then create a very simple test which is designed to load the load balancer as opposed to the webserver, like so:

from locust import HttpUser, task, between

class QuickstartUser(HttpUser):

    @task(1)
    def index_page(self):
        self.client.get("/test.txt")

On the LoadForge configuration side you can choose how many users to send. With this configuration you will typically see each "virtual user" create 1-2 requests per second. In terms of how to spec the load test you can look at this as a guide:

Peak RPS Users Servers
~10,000 RPS10,0001
~50,000 RPS50,0005
~250,000 RPS200,00020

If you are testing plain HTTP or TCP it's much less load on the LoadForge test servers so you may need slightly less.

Maximum performance

LoadForge is able to generate an extremely high amount of load, far more than any single device would be able to fulfill. If you have a very large scale installation though you can scale these tests well beyond the maximums above.

  1. The first component of this is running more than one test at once, e.g. you can run 5x20 server tests for a total of 1,000,000 SSL TPS.
  2. The second component is switching to FastHttpUser instead of HttpUser, which is 4-5x faster in terms of raw TPS.
  3. And the final one is completely removing your wait time between requests.

LoadForge allows for a virtually limitless amount of requests given that you can run any number of tests in parallel. The maximum capacity we have tested is 2,000,000 SSL TPS. Should you need a large scale load test we recommend booking time with us to discuss it.

Analyzing your results

You'll receive live results and a report with graphs from LoadForge. The primary things to look at are:

  • Latency - higher latency indicates an overload
  • P95 Graphs - what the bottom 5% of responses look like
  • Failures - any HTTP failures indicate an issue of course
  • RPS - the primary measure for a load balancer is Requests Per Second or for SSL Transactions Per Second

Managed testing

We provide managed performance testing as well should you need.

Ready to run your test?
Start your first test within minutes.