---
title: "Test load against a budget · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/non-functional-tests/load-tests
updated: 2026-10-20
licence: "All rights reserved"
---

# Test load against a budget

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Non-functional tests](https://agentwranglers.se/playbook/testing/non-functional-tests)
- Rule: Before a launch or a big change, load test the busiest routes and fail when response times or errors pass a set budget.
- How: Write a short load script with a tool such as k6, Gatling or Locust. Run it against staging, never production without warning. Set limits for the slowest responses and the error rate, such as a 95th percentile under 500 ms and under 1 percent errors. Then raise the load in steps until errors or response times pass the limits, and record that point as the service's capacity. Page speed budgets live in the [website playbook](https://agentwranglers.se/playbook/website/performance/performance-budget), and security tests in the [security testing playbook](https://agentwranglers.se/playbook/adversarial-testing/rules-of-engagement/fix-becomes-check). Measure the server's memory after a warm-up over every kind of page. Set a ceiling below the machine's limit, such as 80 percent of it.
- Check: The load test exits with an error when a limit is passed. The latest run before the launch passed. The run also fails when memory passes its ceiling.

Example:

```js
// k6
import http from 'k6/http';
export const options = {
  vus: 50,
  duration: '2m',
  thresholds: { http_req_duration: ['p(95)<500'], http_req_failed: ['rate<0.01'] },
};
export default () => { http.get('https://staging.example.com/products'); };
```

```python
# Locust
from locust import HttpUser, between, events, task

class Shopper(HttpUser):
    wait_time = between(1, 3)

    @task
    def products(self):
        self.client.get("/products")

@events.quitting.add_listener
def fail_over_budget(environment, **kwargs):
    stats = environment.stats.total
    if stats.fail_ratio > 0.01 or stats.get_response_time_percentile(0.95) > 500:
        environment.process_exit_code = 1
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/non-functional-tests/load-tests`.

- Next: [Check accessibility in every build](https://agentwranglers.se/playbook/testing/non-functional-tests/accessibility-in-ci)
- [Non-functional tests](https://agentwranglers.se/playbook/testing/non-functional-tests)
