Locust Metrics and Monitoring: Reading Load Test Results
Locust reports RPS, percentile response times (p50, p95, p99), failure counts, and worker stats. This guide explains what each metric means, how to interpret them during a test, and how to export Locust data to Prometheus, InfluxDB/Grafana, and CSV for post-test analysis.
Running a Locust test is the easy part. Reading the results correctly—knowing which metrics matter, what they're telling you, and when to stop—is where most teams struggle. This guide covers Locust's built-in metrics, their statistical meaning, and how to route them to monitoring infrastructure for long-running or distributed tests.
The Locust UI: What You're Looking At
The Locust web UI at http://localhost:8089 shows four main views:
Statistics Table
The main table shows one row per named request:
| Column | Meaning |
|---|---|
| Name | Request name (URL or custom name via name= parameter) |
| # Requests | Total requests sent so far |
| # Failures | Requests that failed (non-2xx or explicitly marked failed) |
| Median (ms) | 50th percentile response time |
| 95%ile (ms) | 95th percentile response time |
| 99%ile (ms) | 99th percentile response time |
| Average (ms) | Mean response time |
| Min/Max (ms) | Fastest/slowest individual request |
| Average size (bytes) | Average response body size |
| Current RPS | Requests per second in the last sampling window |
| Current failures/s | Failures per second |
Charts
Three real-time charts:
- Total Requests per Second: Combined RPS across all endpoints
- Response Times (ms): p50 and p95 over time
- Number of Users: Current simulated user count
The chart timeline is crucial: you can see exactly when response times degraded as users ramped up, or whether performance was stable throughout.
Failures Tab
Lists every unique failure with its count and a sample error message. Check this tab when failure rate is non-zero—it tells you whether failures are timeouts, 500 errors, or validation failures.
Workers Tab (Distributed Mode)
Shows each connected worker with user count and current RPS. A worker with 0 RPS indicates a crashed or stalled process.
Understanding Response Time Percentiles
Locust reports p50, p95, and p99. Here's what they mean in practice:
- p50 (median): Half your requests are faster, half are slower. This represents the "typical" user experience.
- p95: 95% of requests are faster than this. The 5% above this threshold are your slowest users—often the ones who churn.
- p99: 99% of requests are faster. This catches extreme outliers: database lock timeouts, GC pauses, cold-start latencies.
Why not use average (mean)? Averages are misleading for response times. A response time distribution is typically right-skewed: most requests complete in 100ms, but a few take 5000ms. Those outliers inflate the average significantly while not affecting p50. A p99 of 5000ms with p50 of 100ms tells you far more than "average 200ms."
Good starting targets (adjust for your SLOs):
- p50 < 200ms
- p95 < 500ms
- p99 < 1000ms
Key Metrics to Watch During a Test
RPS Plateau
As users ramp up, RPS should increase linearly. When RPS plateaus or drops despite more users, your system is saturated. New users are queuing behind the backlog rather than generating additional throughput. The plateau point is your system's maximum useful capacity.
Response Time Inflection
Plot p95 over time against user count. Performance typically looks like a hockey stick: flat until you hit a saturation point, then exponential growth. The inflection point marks your reliable operating range.
Failure Rate
A small failure rate (< 0.1%) is often acceptable and may represent real-world conditions. A rising failure rate as users increase indicates your error handling under load—timeouts, rejected connections, database errors. Track whether failures cluster on specific endpoints.
User Count vs RPS Ratio
Calculate RPS / user_count (throughput per user). This should be roughly constant if your wait_time setting is accurate. If it drops as users increase, it indicates server-side queuing.
Exporting Metrics
CSV Export
The --csv flag writes results to CSV files at the end of a test:
locust --headless \
--users 500 \
--spawn-rate 50 \
--run-time 10m \
--host https://api.example.com \
--csv results/test-$(date +%Y%m%d-%H%M)This creates:
results/test-20260526-1030_stats.csv— per-endpoint statsresults/test-20260526-1030_stats_history.csv— time-series dataresults/test-20260526-1030_failures.csv— failure log
The history file is especially useful: it records stats every 10 seconds, so you can plot response times vs. user count over the test duration.
Prometheus Integration
Locust ships with a Prometheus exporter. Install the dependency:
pip install locust-pluginsStart Locust with the exporter:
locust --master \
--host https://api.example.com \
-L locust_plugins.listeners.prometheusThis exposes metrics at http://localhost:9646/metrics in Prometheus format:
locust_requests_total{method="GET",name="/api/products",result="success"} 14523
locust_response_time_seconds_bucket{le="0.1",method="GET",name="/api/products"} 12300
locust_users{} 500Add a Prometheus scrape target:
# prometheus.yml
scrape_configs:
- job_name: locust
static_configs:
- targets: ["localhost:9646"]
scrape_interval: 5sInfluxDB + Grafana Dashboard
For richer dashboards, export to InfluxDB:
# locustfile.py — add InfluxDB listener
from locust import events
import influxdb_client
from influxdb_client.client.write_api import SYNCHRONOUS
INFLUX_URL = "http://localhost:8086"
INFLUX_TOKEN = "your-token"
INFLUX_ORG = "your-org"
INFLUX_BUCKET = "locust"
client = influxdb_client.InfluxDBClient(
url=INFLUX_URL, token=INFLUX_TOKEN, org=INFLUX_ORG
)
write_api = client.write_api(write_options=SYNCHRONOUS)
@events.request.add_listener
def on_request(request_type, name, response_time, response_length, exception, **kw):
point = influxdb_client.Point("locust_request") \
.tag("endpoint", name) \
.tag("method", request_type) \
.tag("success", str(exception is None)) \
.field("response_time_ms", response_time) \
.field("response_length_bytes", response_length)
write_api.write(INFLUX_BUCKET, INFLUX_ORG, point)Import the Locust Grafana dashboard (ID: 12081 from Grafana.com) for a pre-built visualization.
Custom Event Listeners
Locust's event system lets you react to test lifecycle events:
from locust import events
from datetime import datetime
@events.test_start.add_listener
def on_test_start(environment, **kw):
print(f"Load test started at {datetime.utcnow()}")
# Could: notify Slack, create a database record, set a feature flag
@events.test_stop.add_listener
def on_test_stop(environment, **kw):
stats = environment.runner.stats
total = stats.total
print(f"Test complete:")
print(f" Requests: {total.num_requests}")
print(f" Failures: {total.num_failures}")
print(f" p95: {total.get_response_time_percentile(0.95):.0f}ms")
print(f" RPS: {total.current_rps:.1f}")
@events.request.add_listener
def on_request(request_type, name, response_time, response_length, exception, **kw):
if exception:
# Log to your error tracking system
print(f"FAILED: {request_type} {name} — {exception}")Assertions and Pass/Fail Criteria
For CI pipelines, you need the test to fail if performance is unacceptable. Locust doesn't have built-in assertions, but you can check stats programmatically:
from locust import events
@events.quitting.add_listener
def assert_stats(environment, **kw):
stats = environment.runner.stats.total
failures = 0
if stats.fail_ratio > 0.01: # > 1% failure rate
print(f"FAIL: failure rate {stats.fail_ratio:.1%} exceeds 1%")
failures += 1
p95 = stats.get_response_time_percentile(0.95)
if p95 > 500:
print(f"FAIL: p95 {p95:.0f}ms exceeds 500ms threshold")
failures += 1
if stats.current_rps < 100:
print(f"FAIL: RPS {stats.current_rps:.1f} below 100 minimum")
failures += 1
if failures > 0:
environment.process_exit_code = 1With environment.process_exit_code = 1, Locust exits with a non-zero code, failing your CI pipeline.
Locust Stats API
The master process exposes a REST API you can query during a running test:
# Current stats
curl http://localhost:8089/stats/requests | jq '.stats[] | {name, current_rps, p95: .response_times["95"]}'
# Current user count
curl http://localhost:8089/stats/requests | jq '.user_count'
# Stop the test programmatically
curl -X POST http://localhost:8089/stop
# Start a new test
curl -X POST http://localhost:8089/swarm \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "user_count=500&spawn_rate=50"This API enables external orchestration: start a test, poll until duration is reached, check p95, stop, export results.
Interpreting Common Patterns
Flat RPS, Rising Latency
Your app is queuing requests internally (thread pool exhausted, database connection pool full). You've hit max throughput; adding more users just makes everyone slower.
Rising Failures, Stable Latency
Usually indicates rate limiting, circuit breakers tripping, or a hard resource cap (connections, file descriptors). Check what specific error codes the failures return.
Periodic Latency Spikes
Likely GC pauses (JVM, .NET), cron jobs, or cache invalidation storms. The chart's time axis makes these visible—spikes repeat at regular intervals.
Linear Latency Growth with Users
Classic underpowered infrastructure. Every added user adds proportional latency. Add resources or optimize before the next test.
Summary
Locust metrics tell a story: RPS plateau marks capacity, p95 inflection marks degradation onset, failure rate tracks reliability under load. Export to CSV for offline analysis, Prometheus for infrastructure dashboards, or InfluxDB/Grafana for team-visible results. For CI, event listeners and environment.process_exit_code turn Locust tests into automated performance gates that fail builds when your APIs miss SLOs.