Locust Directory

Setting Request Timeouts

How to set a maximum time for a request to come back

Overview

You can set HTTP timeouts on LoadForge by using the timeout parameter. This is useful where you see an even increasing P95/P99 response time as requests that your webserver fails to respond to increase in time.

The value is set in seconds, as is shown below.

Code

from locust import HttpUser, task, between

class QuickstartUser(HttpUser):
    wait_time = between(5, 9)

    @task(1)
    def index_page(self):
        self.client.get('/page1', timeout=10)       
        self.client.get('/page2', timeout=5)        


This guide is part of the LoadForge Directory, an index of locustfile's for use with LoadForge website and API load tests. We also provide a wizard to generate tests, and onboarding assistance for clients. Contact us should you have any questions.

LoadForge provides load testing and stress tests for websites, APIs and servers. It uses your cloud account to rapidly scale large numbers of simulated users to load test your website, store, API, or application for cheap - just cents per test!

For more help on Tests please see our official documentation. Logged in users can also use our wizard to generate a locustfile, or you can record your browser steps.

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