Load tests
A load test runs one scenario over and over, with many virtual users at once, and thresholds decide whether the run passed. Reach for it when the question is not whether the API works but whether it still works at twenty users, and whether the release you are about to ship is slower than the one before it.
A load test goes in a .stamp file above the first request, in the same place a plan goes. The file below is whole. Save it as posts.stamp and it runs as it stands.
load Browsing {
users 5
duration 10s
think 200ms..600ms
threshold p95 < 1500ms
threshold errors < 1%
scenario {
run listPosts
expect status == 200
}
}
### List posts
GET https://jsonplaceholder.typicode.com/posts?_limit=5
Five settings and a scenario:
users 5 | Five virtual users, each running the scenario in a loop, independently of the others. |
duration 10s | Keep going for ten seconds. iterations 500 instead counts scenario runs rather than time. |
think 200ms..600ms | A pause after each scenario run, picked from that range. Without it, five users become the fastest five clients the API will ever meet. |
threshold p95 < 1500ms | The run fails if the 95th percentile of response times comes out above this. |
threshold errors < 1% | And fails if more than one request in a hundred could not be sent or answered with 400 or more. |
scenario { … } | What one virtual user does, once. The statements are the ones a plan uses: run, expect, set, if, wait. |
Ten seconds later it reports what happened.
stamp load posts.stamp
▶ Browsing posts.stamp · 5 users · 10.00 s
requests 113 in 10.21 s, 11.1/s, 0 failed (0.0%)
latency p50 24 ms p90 84 ms p95 104 ms p99 110 ms max 110 ms
checks 113 passed, 0 failed · 113 iterations
listPosts ×113 avg 36 ms p95 104 ms
✓ threshold p95 < 1500ms (104 ms)
✓ threshold errors < 1% (0.00%)
✓ passed
Three lines of totals, then one line per request, so a scenario of six calls says which of the six is the slow one, then the thresholds with the figure each was judged on. The run fails if a threshold did not hold, if a request could not be sent or came back 400 or more, or if an expect did not hold. The thresholds are the part that catches a release which is merely slower than the last one.
One caution before the numbers grow. A load test is traffic, and it goes wherever the request points. Keep the figures small while writing one, and point it at something you own.
That is a load test. What follows is the shape of a real one.
How many, for how long
ramp starts the users evenly over a period instead of all at once, which is both kinder and more like real traffic. The run then lasts for a duration, or until iterations scenario runs have finished between all the users.
users 20
ramp 10s
duration 2m
Those three lines replace the two in the file above; the thresholds and the scenario sit below them unchanged. Twenty users, one more every half second, then two minutes at full strength.
A request that cannot be sent, or that answers with 400 or more, counts as a failed request; a failed expect counts as a failed check. The two are reported separately because they usually mean different things: the first is the API falling over, the second is the API answering, wrongly.
Thresholds, and the exit code
A threshold is a metric, a comparison and a value. Each one is printed with the figure it was judged on, and a single failure makes the command exit with 1, which is what puts a load test in a pipeline next to the unit tests.
p50, p90, p95, p99 | Percentiles of response time. p95 < 800ms is the usual one: the slowest one request in twenty. |
avg, max | Mean and worst response time. |
errors | The percentage of requests that failed. |
checks | The percentage of expect lines that held. checks > 99% catches an API that answers quickly with the wrong thing. |
rps | Requests per second achieved. Written as a lower bound, rps > 40, it is a throughput floor. |
requests | How many were sent in all. |
When something does go wrong, the failures are grouped and counted under the thresholds, so a wall of identical errors arrives as one line.
stamp load posts.stamp
▶ Browsing posts.stamp · 4 users · 12 iterations
requests 12 in 687 ms, 17.5/s, 6 failed (50.0%)
latency p50 203 ms p90 332 ms p95 332 ms p99 332 ms max 332 ms
checks 6 passed, 6 failed · 12 iterations
flaky ×12 avg 228 ms p95 332 ms 6 failed
✗ threshold p95 < 50ms (332 ms)
✗ threshold errors < 1% (50.00%)
×6 flaky: HTTP 500
×6 status == 200 (status is 500)
✗ failed
Signing in once
setup runs once for the whole test, before any user starts. Every scenario run then begins from a copy of the session the setup left behind, so one login serves all twenty users and the login itself is not measured.
Inside the scenario, three numbers say where you are: vu is the virtual user, iteration is that user's count, and run is the count across the whole test. All three start at 0.
load Orders {
users 10
duration 30s
setup { run logIn }
scenario {
run listOrders with page = iteration
expect status == 200
}
}
Data that holds together across a run
A scenario that creates something and then reads it back needs the same id in both requests, a different id next time round, and the same set of ids when the test is run again. A seed gives all three: each scenario run gets its own seed, <seed>-<run>, and a keyed value is the same everywhere that key appears within one run.
load Orders {
users 20
ramp 10s
duration 2m
think 200ms..1s
seed friday-orders
threshold p95 < 800ms
threshold errors < 1%
threshold checks > 99%
setup { run logIn }
scenario {
run placeOrder with orderId = uuid("order")
expect status == 201
run lookupOrder with orderId = uuid("order")
expect body.orderId == uuid("order")
}
}
uuid("order") is one id inside one scenario run and a different one in the next, so the two requests agree and the orders do not collide. person(key), address(key) and mock(schema, key) follow the seed the same way, which is how a run gets twenty customers whose names and email addresses belong together. Drop the seed and every value is random again.
The load test above names three requests that live elsewhere in the workspace, so it is not a file on its own. Sample data that holds together is the longer version of this.
Everything a load test can hold
users 20 | Virtual users running the scenario in parallel |
ramp 10s | Start them evenly over this period |
duration 2m | How long to keep going |
iterations 1000 | Or how many scenario runs in total, instead of a duration |
think 200ms..1s | A pause after each scenario run, from this range |
seed friday-orders | Repeatable random and keyed data |
threshold p95 < 800ms | One per line; all of them have to hold |
tags load | What --tags selects on |
setup { … } | Runs once, before the first user |
scenario { … } | What one user does, once |
stamp load . # every load test in the workspace
stamp load . Browsing # one by name
stamp load . env=staging # pick the dimension values yourself
stamp load . --json results.json # the totals, the thresholds, the per second series
stamp load . --html report.html # the same, as a page that draws itself
In the app
- Pick the load test under Load Tests in the sidebar. Until it has run it says Not Run Yet, with how many virtual users for how long, and the line under the name repeats the settings: the users, the ramp, the duration or the iterations, the think range, the seed.
- Check the selector in the header for the dimension values, then press ⌘↩ for Run Load Test. Stop ends it early.
- Five tiles across the top move while it runs: Requests with the iterations so far, Throughput with the users active, p95 with p50 and p99 under it, then Errors and Checks, which turn red as soon as one fails.
- Under them three charts fill in second by second: Requests per second with the failures stacked on it in red, p95 latency, and Active users climbing through the ramp.
- Requests is there from the first second: a row per request, slowest first, with how many were sent, how many failed, and a bar reaching its 95th percentile with the average marked. A failure count is red and a zero is dimmed, so the row that went wrong is the one that stands out. When the run ends, Thresholds joins it above with the figure each one was measured at, and What Went Wrong below, each distinct failure with the number of times it happened.
- Export writes the HTML or JSON report, and Results and Source in the toolbar switch between this and the text of the test.
A load test is a shape over time, and a command can only print that shape once it is over. Here the charts draw themselves while the run is still going, so a p95 that starts climbing after the ramp finishes is something you watch rather than something you reconstruct.

Next: Test plans for the statements a scenario is made of, Sample data that holds together for seeds and keyed records, and Reports for the file you hand to somebody else.