Skip to main content
hitspec includes built-in stress testing. Add --stress to your run command and your functional tests become load tests — no separate tool required.

Quick Start

Two Modes

Rate Mode

Controls throughput by setting a target number of requests per second:

Virtual Users (VU) Mode

Simulates concurrent users, each making sequential requests with optional think time between them:

Ramp-Up

Gradually increase load instead of starting at full capacity:
This linearly increases the request rate from 0 to 200 over the first 30 seconds, then holds at 200 for the remaining duration.

Thresholds

Set pass/fail criteria for CI/CD pipelines. If any threshold is exceeded, the command exits with a non-zero code:
Available threshold metrics:

Thresholds in profiles

In a hitspec.yaml stress profile, a threshold value may start with an operator: p95: "<=250ms", rps: ">=100", errors: "<=0". Without one, latency, error and assertion thresholds mean “less than” and rps means “greater than”. Quote values that start with an operator.

Assertions, Errors and Incomplete Requests

Requests that have expect assertions are checked in stress mode too. The results are kept apart so each threshold means one thing:
  • Errors (errors<...) are requests that failed in transport (connection refused, a client timeout, …) or came back with a non-2xx status. A non-2xx status that the request’s own expect status accepts (expect status 404 and the response is a 404) is expected, so it is not an error.
  • Assertion failures (assertions<...) are responses where at least one expect did not hold. A 200 whose body assertion fails is a success for errors and a failure for assertions. The summary prints Assertions: N checked, M failed, and --stress-json reports checked, failed and failureRate. snapshot assertions are skipped under load.
  • Incomplete requests were still in flight when the duration ended. They are reported on their own line and are not counted as requests, successes or errors, so a slow tail at the end of the window no longer inflates your error rate.
A run that falls more than 10% short of its target --rate prints a warning. When the server (or --max-vus) cannot keep up, the test sends less load than you asked for and the latencies understate what clients arriving on schedule would see, so do not read them as “the server handled N req/s”.
You can also assert on percentile latencies in your expect blocks:

Stress Testing Flags

Per-Request Annotations

Control how individual requests behave during stress tests:

Available Annotations

Setup and Teardown

Use @stress.setup and @stress.teardown for one-time operations:

Stress Profiles

Define reusable stress configurations in hitspec.yaml:
Run a profile:
A flag you pass on the command line overrides the profile, even when it equals the flag’s default (--rate 10 wins over a profile’s rate: 100). Settings you do not pass come from the profile.

Using Profiles from studio

The hitspec studio stress screen runs a saved profile by name. Type it in the profile field and start the test: the profile’s duration, rate, VUs and thresholds apply, and any other field you fill in overrides it. The idle screen lists the profiles saved in hitspec.yaml. The desktop app can also create, edit, and delete profiles; changes are persisted to hitspec.yaml automatically.

Results Panel

After a stress test completes (either naturally or via stop), studio displays a results view with:
  • Summary cards — Total requests, average RPS, success rate, and error count
  • Latency percentiles — Min, P50, P95, P99, Max, Mean, and Standard Deviation (all in fractional milliseconds)
  • Per-request breakdown — A table showing each request’s count, success/error split, and individual latency metrics (avg, min, max, P50, P95, P99)
  • Threshold indicators — Pass/fail badges for each configured threshold
Click Run Again to return to the configuration view and start another test. The results are also available programmatically via the GET /api/v1/stress/result endpoint.

Testing Directories and Multiple Files

Stress testing works with directories and multiple files:

Understanding Rate Limits

Your server may have its own rate limits. High failure rates often indicate you are exceeding them.
Start with a low rate and increase gradually. If you see high failure rates (above 10%), reduce --rate and --max-vus. Exactly N successes in 60 seconds often reveals a server-side rate limit of N req/min.

CI/CD Integration

Use stress testing in GitHub Actions with thresholds:

Metrics Export

Export stress test metrics to monitoring systems:
See the CI/CD integration guide for more details.
Last modified on October 19, 2026