---
title: "Test load against a budget · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/performance-tests/load-tests
id: TST-36
level: Recommended
updated: 2026-10-22
build: a2a6bdfed830
tokens: 1331
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Test load against a budget

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Performance tests](https://agentwranglers.se/playbook/testing/performance-tests.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: TST-36
- Level: Recommended
- Chapter: [Performance tests](https://agentwranglers.se/playbook/testing/performance-tests.md)
- Rule: Before a launch or a big change, load test the busiest routes and fail when response times or errors pass a set budget.
- 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.
- 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.md), and security tests in the [security testing playbook](https://agentwranglers.se/playbook/adversarial-testing/rules-of-engagement/fix-becomes-check.md). 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.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript 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 example

```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
```

## Sources

- [Azure Well-Architected performance testing](https://learn.microsoft.com/en-us/azure/well-architected/performance-efficiency/performance-test)
- [k6 thresholds](https://grafana.com/docs/k6/latest/using-k6/thresholds/)

## Related rules

- WEB-58 [Fail the build when pages get heavier](https://agentwranglers.se/playbook/website/performance/performance-budget.md) in Website
- SEC-7 [Turn every fix into a check](https://agentwranglers.se/playbook/adversarial-testing/rules-of-engagement/fix-becomes-check.md) in Adversarial testing
- TST-53 [Run load tests from a written runbook](https://agentwranglers.se/playbook/testing/performance-tests/load-test-runbook.md) in Testing
- TST-51 [Hold normal load for hours to find leaks](https://agentwranglers.se/playbook/testing/performance-tests/soak-tests.md) in Testing
- TST-61 [Catch speed regressions on every pull request](https://agentwranglers.se/playbook/testing/performance-tests/benchmark-regressions.md) in Testing
- OPS-38 [Walk through a launch checklist before users arrive](https://agentwranglers.se/playbook/operations/running-the-service/launch-readiness.md) in Operations and observability
- OPS-39 [Keep headroom](https://agentwranglers.se/playbook/operations/capacity-and-resilience/headroom.md) in Operations and observability
- OPS-41 [Size the runtime's memory to the box](https://agentwranglers.se/playbook/operations/capacity-and-resilience/runtime-memory-limits.md) in Operations and observability
- INF-62 [Test the service against every platform limit](https://agentwranglers.se/playbook/infrastructure/hosting-platforms/platform-limits.md) in Infrastructure and environments
- STK-97 [Use Locust for load tests](https://agentwranglers.se/playbook/stack/testing-and-code-quality/locust.md) in Software choices
- SCL-1 [Find the bottleneck before you add servers](https://agentwranglers.se/playbook/scaling/measure-before-you-scale/find-the-bottleneck.md) in Scaling
- SCL-3 [Write down the load you plan for](https://agentwranglers.se/playbook/scaling/measure-before-you-scale/load-model.md) in Scaling
- SCL-40 [Spread writes that all land on one row](https://agentwranglers.se/playbook/scaling/growing-the-database/hot-rows.md) in Scaling

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/testing/performance-tests/load-tests">Agent Wranglers testing playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Run load tests from a written runbook](https://agentwranglers.se/playbook/testing/performance-tests/load-test-runbook.md)
- [Performance tests](https://agentwranglers.se/playbook/testing/performance-tests.md)
