← Load Test Directory

Enhancing Test Performance with FastHTTP

Leverage the FastHttpUser class to optimize load test throughput on LoadForge.

You are now browsing the LoadForge locust test directory. You can use these tests as a starting point for your own tests, or use our AI wizard to generate one automatically.



By default, LoadForge harnesses the capabilities of the HttpUser class, an interface built atop Python's renowned requests library. While this provides vast opportunities to tailor your test, it may sometimes offer more than you need.

For those eyeing improved throughput, LoadForge introduces FastHttpUser—a class that promises to amplify your test capacity by 4-5x, facilitating a greater number of requests per second compared to the default HttpUser.

For Advanced Users

Please tread cautiously: FastHttpUser is an advanced feature. While it assures speed, it sacrifices some of the functionalities inherent to the HttpUser class. It may not suit every user or every use case.

Sample Test with FastHttpUser

Here's a succinct test showcasing the usage of FastHttpUser. This test is devoid of any wait_time and is primed to deliver the zenith number of requests for each virtual user.

from locust import task, FastHttpUser

class MyUser(FastHttpUser):
    def index(self):
        response = self.client.get("/")

Advanced Test with FastHttpUser

Suppose you have an e-commerce site and want to test the performance of various pages: the homepage, product listings, and individual product pages. The following test simulates these scenarios using FastHttpUser:


from locust import task, FastHttpUser, between
import random

class EcommerceUser(FastHttpUser):
    wait_time = between(1, 5)  # simulates user thinking time between 1 to 5 seconds

    @task(3)  # 3 times more likely to visit the homepage than other pages
    def visit_home(self):

    def browse_products(self):

    def view_single_product(self):
        # this function would return a random product ID
        product_id = self.random_product_id()  

    def random_product_id(self):        
        # assuming there are 1000 products
        return random.randint(1, 1000) 

Weights & Endpoints

In this advanced example, you'll notice the @task decorators are given different weights. These weights dictate the likelihood of a particular endpoint being hit. A higher weight means the task will be executed more frequently. This simulates real-world scenarios where users are more likely to visit some pages (like the homepage) than others.

Remember, while FastHttpUser accelerates the request throughput, you might miss out on some of the functionalities offered by the standard HttpUser. Always make sure to weigh the pros and cons based on the specific requirements of your testing scenario.

Harness the Power of Locust

LoadForge is built on the sturdy foundation of locust.io, an open-source load testing framework. If you're already a user of locust.io, this script will look familiar. Interested in escalating your testing game? Import your locust.io script into LoadForge and tap into a world of enhanced testing!

Ready to run your test?
Run your test today with LoadForge.