Skip to content

Load testing

← Index

Load testers such as Locust, k6 and Gatling see an application from the outside. They can tell you the p95 doubled at 150 requests per second. They cannot tell you which query went from 3 ms to 410 ms. Redline's profiler sees the inside, one request at a time. The load tester joins the two: it drives your app at a controlled rate, tags every request, and then shows, per step of the test, what got slower inside the server.

Bottlenecks                      10 rps     50 rps    100 rps   150 rps    growth
SELECT ... FROM shop_order ...    3.1 ms     4.0 ms    62 ms    410 ms     132x
GET /api/orders                    18 ms      24 ms    120 ms   690 ms      38x

It ships in redline-core. Install the load extra (it needs httpx):

pip install "redline-core[load] @ git+https://github.com/Pythondeveloper6/redline#subdirectory=packages/redline-core"

The command is redline.

Concepts

You can skip this section and use the quickstart, but the three ideas below decide whether a load test tells you the truth.

Open versus closed model

flowchart LR
    subgraph closed["Closed model: N users in a loop"]
        direction LR
        u1[user] --> s1[send] --> w1[wait for response] --> t1[think] --> u1
    end
    subgraph open["Open model: fixed arrival rate"]
        direction LR
        clock(["clock: R requests per second"]) --> s2[send] --> srv[server]
        clock --> s3[send] --> srv
        clock --> s4[send] --> srv
    end

A closed model runs N virtual users in a loop: send a request, wait for the response, think, send the next. When the server slows down, the users slow down too, so the offered load falls exactly when you most need it to hold. The test politely stops hurting the server it is meant to stress.

An open model sends requests at a fixed arrival rate, whether or not earlier ones have finished, the way independent users on the internet behave. When the server slows down, requests pile up, queues grow and latency climbs, which is what happens in production. Redline uses the open model: you choose requests per second, not users.

Many internal applications are sized by a fixed number of logged-in users, not by a rate. For that, keep the open model and add sessions: an arrival starts one session (a flow), the session waits think_s between its steps like a person reading a page, and by Little's law the number of sessions in flight is the arrival rate times the session length. 20 arrivals per second with 5 s of think time holds about 100 sessions at once, and the run reports the peak per step (Sessions and think time). The offered load still does not fall when the server slows.

Coordinated omission

A load generator that waits for each response before sending the next one measures the wrong thing: if one request stalls for two seconds, it silently omits the requests it should have sent in that time, and the slow period is under-counted. This is coordinated omission, and it makes latency charts look much better than reality.

Redline schedules each arrival on a timetable and measures latency from the scheduled time, not from when the request was finally sent. If the generator was late, or the connection pool was busy, that waiting counts. Arrivals that cannot even be started because too many requests are already in flight are counted as dropped and shown in the results, never hidden.

The knee

Plot achieved throughput and p95 latency against offered load. For a while the server keeps up: latency is flat, throughput follows the target. Then, at some load, it bends: latency shoots up, errors appear, or throughput stops following the target. That bend is the knee, and the load just before it is your maximum healthy rate.

Redline finds the knee for you in a ramp or step test. It is the first complete step where any of these is true:

  • p95 is more than 2x the first step's p95;
  • the error rate is above 1%;
  • the achieved rate is below 90% of the target.

The p95 rule compares with the first step, so the first step can only be the knee through errors or a missed target. A step cut short by a stop is reported but never decides the knee.

Quickstart

  1. Start your app (with Redline mounted, so the run can be correlated; see below).
  2. Generate a scenario from what Redline already knows:
redline load init --from-traces -o scenario.toml

or from an OpenAPI schema:

redline load init --from-openapi http://localhost:8000/openapi.json -o scenario.toml
  1. Open scenario.toml, check the base_url and the request list, and set weights.
  2. Run a step test:
redline load scenario.toml --steps 10:100:10 --step-duration 20s

That is 10, 20, ... 100 requests per second, 20 seconds each.

  1. Read the table, then open the run in the UI (the link is printed at the end as "Open the run in Redline: …") to see the chart and the bottlenecks. The link uses --ui-url, else the scenario's ui_url, else mount_path from your project's Redline config, else /_redline; with Django (mounted where your URLconf puts it, often /redline/) pass --ui-url /redline or set ui_url in the scenario.
redline load: browse → http://127.0.0.1:8000
run 7c1e...: steps 10 to 100 rps by 10, 20s each
step   target  achieved    sent      ok    err   drop      p50      p95      p99      max   err%
   1     10.0      10.0     200     200      0      0     12ms     21ms     38ms     64ms   0.0%
   2     20.0      20.0     400     400      0      0     13ms     23ms     41ms     70ms   0.0%
   ...
   7     70.0      69.8    1396    1390      6      0     41ms    190ms    420ms    910ms   0.4%
   8     80.0      71.2    1424    1380     44      0    210ms    1.40s    2.10s    3.50s   3.1%

total: sent 6420  ok 6370  errors 50  dropped 0  p50 38ms  p95 410ms  p99 1.80s
knee: step 8 – error rate 3.1% > 1%
max ok rps: 69.8
verdict: saturated (knee at step 8 (80 rps): error rate 3.1% > 1%)

Test an environment you own

A load test is an attack on whatever it points at. Run it against your own local, staging or review environment. Never point it at a production system, a shared dependency or someone else's service. In a shared staging environment, tell the people who use it.

Correlating with the app

Every request carries a header X-Redline-Run: <run_id>;step=<n>. A Redline-instrumented app turns it into the trace tags run_id and step, as long as that run is in the app's store and running (or ended less than a minute ago): a made-up header tags nothing, and a run with --no-store, or written to another store, does not tag the app's traces. The bottleneck analysis joins those tags with the per-query summaries, so the app must be recording the load. Remember sampling: in a profile that keeps 5% of requests you still get enough traces at high rps, but at 5 rps you may get none. Requests tagged with a run that is registered in the app's store and running are always kept (sampled_by is run), so a low-rate step still produces traces without changing sample_rate.

The run itself (its steps and latency histograms) is written to the same store the app uses. The default is .redline/redline.db in the working directory, and --store points elsewhere, so run the command from the app's directory or pass the path. The UI then lists it under Load.

Checking that the app records the run

Before the first step, redline load can send one harmless request (the scenario's first enabled GET, tagged step=probe, which the bottleneck analysis ignores) and look for the trace it should have produced. If none appears it says why it usually happens: the app uses a different store than the run, sampling dropped the request, or recording is disabled.

  • With --store-url or --register-url the probe is on by default and only warns.
  • With a file store it is off, so existing runs send no extra request; add --probe to turn it on.
  • --require-recording stops the run (status failed) instead of warning.
  • --no-probe skips it; --probe-timeout 10s waits longer for a slow writer.

Generator and application on different machines

When the generator runs on another host (or the app runs in a container) there is no shared file, and a run written to a local file would tag none of the app's traces. Two options:

  • Shared store. Point both at the same PostgreSQL database: redline load scenario.toml --store-url postgresql://... (or set storage_url in the project's config, which redline load picks up when --store is not given). The URL's password is never printed.
  • Register over HTTP. With no shared store, the generator tells the application about the run: redline load scenario.toml --register-url https://app.example/_redline. The application must enable accept_remote_runs (off by default, and always off while read_only is on). The Redline access token is read from REDLINE_TOKEN or --token-file, never from the command line. The generator checks the application is reachable and accepts the token before the first request, and only runs registered this way can be changed over HTTP, never runs written by a local process.

Profiles

A profile says how the rate changes over time.

Mode Shape Parameters
constant one step at a fixed rate rps, duration_s
ramp the rate rises (or falls) linearly start_rps, end_rps, duration_s, step_duration_s (default 5 s)
steps a staircase start_rps, end_rps, step_rps, step_duration_s (default 30 s)
stages any shape: spike, soak, a pause stages: a list of { rps, duration_s } (rps = 0 is a pause)

Results are reported per step. A ramp is reported in steps too (each at the ramp's rate at the step's midpoint), so the knee finder works on it. Prefer steps when looking for a knee: each step is long enough for a stable p95, and "the server held 70 rps and broke at 80" is a sentence you can act on.

Spikes, soaks and custom shapes

stages runs an ordered list of { rps, duration_s } stages, each reported as one step:

[profile]
stages = [
  { rps = 10,  duration_s = "1m" },    # normal
  { rps = 200, duration_s = "30s" },   # the spike
  { rps = 10,  duration_s = "3m" },    # does it recover?
]

On the command line: --stages 10:1m,200:30s,10:3m. A soak is one long stage (--stages 40:30m). Two extra analyses make these shapes useful:

  • Recovery. A step where the rate falls never decides the knee (that is recovery, not saturation). Instead the summary reports, for each such step, the p95 before the spike, the peak, and how many seconds after the step began p95 was back within 25% of its level before the spike for three seconds running (recovered_after_s, or null if it never was).
  • Drift. Any step of 30 s or more is checked for slow growth, comparing its first third with its last: degrading when p95 grew by 25% and at least 5 ms with a positive slope, or the error rate climbed by a percentage point; otherwise stable. The summary has the slope in ms per minute, and drift_verdict is degrading if any step is. A leak shows up here long before the knee.

stop_on ends the run after the first step that breaches a limit, so a test does not keep hammering a server that has already fallen over:

[profile]
mode = "steps"
start_rps = 10
end_rps = 200
step_rps = 10
step_duration_s = "20s"
stop_on = { error_rate = 0.05, p95_ms = 2000 }

Arrivals are evenly spaced by default. poisson = true (or --poisson) uses random inter-arrival times with the same mean, which is closer to independent real users and produces burstier queues.

Scenario reference

A scenario is a TOML file (Python 3.11 or newer, or the tomli package), a JSON file, or a Python file that defines SCENARIO = {...}.

name = "browse"
base_url = "http://127.0.0.1:8000"
headers = { Accept = "application/json" }
timeout_s = 10

[[requests]]
name = "orders"
path = "/api/orders/?page={random_int:1:20}"
weight = 3

[[requests]]
name = "order detail"
path = "/api/orders/{random_int:1:500}/"
weight = 5

[[requests]]
name = "add to cart"
method = "POST"
path = "/api/cart/"
json = { sku = "A-1", qty = 1 }
expect_status = [200, 201]

[profile]
mode = "steps"
start_rps = 10
end_rps = 100
step_rps = 10
step_duration_s = "20s"
stop_on = { error_rate = 0.05, p95_ms = 2000 }

Top-level keys

Key Default Meaning
name file name Shown in the UI
description Free text
base_url required, here or with --base-url http:// or https:// root of the app. Requests use paths only
headers {} Sent with every request
timeout_s 10 Per-request timeout. A timeout is an error
requests required A non-empty list. At least one needs weight > 0
profile constant 10 rps for 30 s See Profiles
workers min(CPUs, 8) Worker processes
connections 64 Keep-alive connections per worker
max_inflight 1000 In-flight cap per worker; arrivals beyond it are counted dropped
seed random Integer seed for placeholders and request choice, for repeatable runs
ui_url config mount_path, else /_redline Where the Redline UI is mounted (path on base_url's host, or a full URL); only used for the printed link
identities, identities_file, identity_mode none Many users instead of one: see Identities
data none CSV / JSON Lines files that fill {data:source.column}: see Data feeds
auth none A token provider refreshed during the run: see Token refresh
flows none Weighted journeys of chained requests: see Flows. requests may then be empty

Durations accept a number of seconds or strings such as "20s", "2m".

Request keys

Key Default Meaning
name method and path Label in results
method GET GET, HEAD, OPTIONS, POST, PUT, PATCH, DELETE
path required Must start with /. May contain placeholders
weight 1 Relative frequency. 0 keeps the request in the file but never sends it
headers {} Added to the top-level headers
json none A JSON body; sets Content-Type: application/json
body none A raw string body
expect_status any status below 400 A list of acceptable status codes. Anything else counts as an error
expect none Rules the response must satisfy: see Response checks
max_ms none A success slower than this counts as an assertion failure
extract none Values to read from the response for later steps of a flow

Placeholders

Rendered separately for every request:

Placeholder Result
{random_int:A:B} a random integer from A to B, inclusive
{random_choice:a\|b\|c} one of the listed values
{uuid} a fresh random UUID (32 hex digits, no dashes)

| {data:source.column} | a value from a data feed; also works in headers, JSON and raw bodies |

Any other {...} in a path is an error, so an OpenAPI path such as /orders/{id} can never be sent by accident.

Flows

Real traffic is journeys: list, open one item from that list, save it. A random detail id often does not exist or is not the caller's, so much of the load turns into cheap 403 and 404 responses. A flow is an ordered list of requests that one arrival runs:

[[flows]]
name = "browse"
weight = 3

[[flows.steps]]
path = "/items"
extract = { id = "$.items[0].id" }          # a JSON path (shorthand), or ...
# extract = { tok = { header = "X-Next" }, n = { regex = "id=(\\d+)", group = 1 } }

[[flows.steps]]
path = "/items/{var:id}"                    # {var:name} works in the path, headers, JSON and body
expect = [{ json = "$.name" }]

One arrival starts one flow, so the open model stays intact. The latency of a flow is measured from its scheduled start to the end of its last step, and each step has its own numbers. A failed step ends the flow and is counted once as a flow error, with the class of the failing step (a status code, an exception, assertion, or extract when a value the next step needs was not in the response). The identity and data row stay the same for the whole flow. The run summary has a flows entry (runs, errors, p50/p95/p99, per-step counts and percentiles) that the CLI prints, and the app's traces carry flow and fstep tags next to run_id and step, so the bottleneck table gets rows for every step of the journey. Plain requests and flows can be mixed; each arrival picks one by weight.

Sessions and think time

A flow can model a user instead of a burst:

[[flows]]
name = "shopper"
think_s = [2, 6]          # seconds between steps: a number, "3s", or a [min, max] range
own_connection = true     # each session opens its own connection, like a separate browser

[[flows.steps]]
path = "/products"

[[flows.steps]]
path = "/products/{var:id}"

think_s is picked at random per pause (seeded by the scenario seed) and a stop cuts it short. The flow's latency includes the pauses, a step's own latency does not. With own_connection the session does not share the worker's keep-alive pool: it connects, sends its steps and closes, so the server sees as many connections as there are sessions. Every step of the run table reports the peak sessions in flight (summed over the workers' own peaks), printed by the CLI and in summary.sessions. To hold N sessions of length L seconds, use rps = N / L.

Response checks

Under load many apps answer 200 with an error body, an empty list or a truncated payload; by default those count as successes. Add expect to a request (one rule or a list):

Rule Passes when
{ json = "$.items[0].id" } the JSON path exists (exists = false to require it absent)
{ json = "$.status", equals = "ok" } the value equals this
{ contains = "text" } / { not_contains = "text" } the body does / does not contain it
{ min_bytes = 200 } the body is at least this large
{ header = "Content-Type", contains = "json" } the header exists (and equals / contains match)

A failed rule is counted as its own error class, assertion, in the error breakdown, and max_ms does the same for a response slower than an agreed limit. Failure reasons never include body or header values.

Several generator hosts (agents)

A generator on the machine under test distorts both sides, and one host caps the offered rate. Run redline load agent on other hosts and point the controller at them:

# on each generator host (token file mode 0600; use TLS or a private network)
redline load agent --listen 0.0.0.0:7700 --token-file agent.token --cert agent.pem --key agent.key

# on the controller
redline load scenario.toml --steps 100:1000:100 \
    --agents https://gen1.internal:7700,https://gen2.internal:7700 \
    --agent-token-file agent.token --agent-ca ca.pem

The controller computes the step plan once and gives each agent its share of the workers (up to 8 each, never more than the peak rps), numbered globally, so the union of all hosts' arrivals is exactly the planned rate. One shared start time is converted to each agent's clock from a measured offset, and every agent's per-second numbers (counters and latency histograms) stream back and merge exactly like local workers', so steps line up to the second. The controller runs no workers itself unless you also pass --workers. Stopping the run (Ctrl-C, stop_on) stops the agents; an agent that disappears fails the run with a clear message.

What the controller sends is the scenario's requests plus its identities and data rows inline (an agent reads no files), so the config, including credentials, crosses the network: use TLS (--cert/--key, verified with --agent-ca) or a private network. An agent needs a token (at least 16 characters), listens on 127.0.0.1 unless told otherwise, refuses auth.provider command and python (use request), blocks link-local and metadata targets, and can be limited with --allow-target URL_PREFIX (scheme, host and port must match exactly; names are resolved and every address checked, but a name that changes its answer later, DNS rebinding, is not caught: use the allow-list).

Each worker also reports its own CPU use. A step where a generator worker was above 90% of a core is marked generator_limited (and listed in summary.generator.limited_steps): the generator, not the app, may have capped the rate there, so add agents before believing the knee.

Streams and WebSockets

Every request is timed to its first byte (headers received) as well as to its last byte. The step table's latency is the last byte; first byte is in each step's ttfb_p50_ms / ttfb_p95_ms and the run summary, and the CLI prints both. A response that streams for a while shows the difference: the first byte is what the user feels.

A request can hold a connection open instead of finishing:

[[requests]]
name = "live feed"
type = "stream"            # server-sent events or a chunked response
path = "/events"
hold_s = 30                # how long to hold it open
weight = 1

[[requests]]
name = "chat"
type = "websocket"         # needs: pip install "redline-core[load-websocket]"
path = "/ws"
messages = ["hello", { type = "ping" }]   # sent in order; each reply is timed
hold_s = 60                # then keep the connection open this long
reply_timeout_s = 5

For these, the latency in the step table is the time to the first byte (stream) or to the handshake (WebSocket): the hold is not latency. Each step also reports how many were held, events received (a server-sent event, or a chunk for other streams), messages answered, the highest number open at once (summed over the workers' own peaks, so exact only when they are balanced), the time to the last byte of a stream and the connect and reply latency of WebSockets. A held stream occupies one of the worker's connections and an arrival slot (max_inflight): to hold 500 at once with 2 workers set connections = 300 or more. They cannot carry a request body, and headers (identities, tokens) are sent on the handshake.

Browser pages

Browser-side cost (rendering, bundle size, requests per page) is out of scope: Redline does not drive a browser. To get the server side of real page loads grouped like a load run, run a browser automation script (any tool) that adds one header to every request of a page load:

X-Redline-Run: <run id>;step=1;page=checkout-17

with a run registered in the app's store (redline load registers one; or POST api/runs/register with accept_remote_runs). The app tags those traces with page, and GET api/runs/{id}/pages sums them per page load: requests, total server time, queries and the slowest route.

Identities

One set of credentials makes the app see one user thousands of times: per-user caches stay warm and row-level filters always pick the same rows. Give the run many users:

identity_mode = "round_robin"      # or "random" (seeded) or "sticky"
identities_file = "users.csv"      # name, header:X-Api-Key, cookie:session ...

[[identities]]
name = "alice"
headers = { Authorization = "Bearer ${ALICE_TOKEN}" }   # ${VAR} reads the environment
cookies = { sid = "${ALICE_SID}" }

Inline identities come first, then the file's. CSV columns are name, header:<Header-Name> and cookie:<name>; a .jsonl file holds {"name", "headers", "cookies"} objects. A missing environment variable fails the run before any request, naming the variable. Header order: scenario headers, then the identity's, then the request's own.

round_robin cycles through every identity (all workers together visit them in order), random picks with the scenario seed, and sticky gives each worker process one fixed identity (one virtual user per process).

Only the identity name is ever recorded: as the identity tag on the app's traces (filter with tag=identity:alice), and as per-identity request counts in the run summary. GET api/runs/{id}/bottlenecks?identity=alice splits the bottleneck table to one user. Header and cookie values are masked in the stored run config.

Data feeds

Uniform random identifiers hit rows that do not exist and hit every real row equally, so the page cache and query plans behave nothing like production.

[[data]]
name = "orders"
file = "orders.csv"      # CSV with a header row, or .jsonl
pick = "zipf"            # "sequential", "random" or "zipf" (first rows hottest)
zipf_s = 1.1             # skew for zipf

[[requests]]
path = "/orders/{data:orders.id}"
json = { sku = "{data:orders.sku}" }

Relative files resolve against the scenario file. Every reference to one source in a request uses the same row. A missing file or column fails the run before any request. zipf and random follow the scenario seed. redline load init --from-traces --data-dir DIR writes the distinct paths seen per endpoint as such files, most used first, instead of one sample path per endpoint.

Token refresh

Short-lived tokens expire mid-run and every request then fails with 401, which looks like a knee. An auth block gets a token before the run and refreshes it before it expires, outside the latency numbers:

[auth]
provider = "request"                 # "command", "request" or "python"
request = { method = "POST", path = "/login", json = { user = "load", password = "${LOAD_PW}" } }
extract = "data.access_token"        # dotted path into the JSON response
expires_extract = "data.expires_in"  # lifetime in seconds (or set ttl_s)
refresh_before_s = 30

command = ["get-token", "--env", "perf"] runs a program (no shell) and reads its output; callable = "package.module:function" calls a Python function returning the token or (token, ttl_s). The token goes in Authorization: Bearer ... (header and prefix change that). Each worker refreshes on its own; refresh calls are never counted in the histograms. If a refresh fails twice, the run stops with an error instead of reporting 401s as server errors. The stored config masks command arguments and request credentials.

auth, identities, identities_file and data can run a program or read a file, so they are accepted only from a scenario file, never from the UI or POST api/runs.

Authentication

Put credentials in headers. Do not commit tokens: read them from the environment in a Python scenario.

# scenario.py
import os

SCENARIO = {
    "name": "authenticated browse",
    "base_url": "http://127.0.0.1:8000",
    "headers": {"Authorization": f"Bearer {os.environ['LOAD_TOKEN']}"},
    "requests": [{"path": "/api/orders/", "weight": 1}],
    "profile": {"mode": "constant", "rps": 50, "duration_s": 30},
}

CLI reference

redline load SCENARIO [options]. Options override the scenario:

Option Meaning
--rps N constant rate
--ramp A:B ramp from A to B rps over --duration
--stages RPS:DURATION,... ordered stages, for example 10:1m,200:30s,10:3m (spike) or 40:30m (soak)
--agents URL,URL run workers on remote redline load agent hosts; the controller runs none unless --workers is given
--agent-token-file PATH, --agent-ca PATH the agents' token (else REDLINE_AGENT_TOKEN) and the CA bundle that verifies their TLS certificates
--steps A:B:STEP steps from A to B rps, STEP apart, each --step-duration
--duration 60s total duration (default 30 s for constant and ramp)
--step-duration 30s length of each step
--poisson Poisson arrivals instead of evenly spaced
--workers N worker processes
--base-url URL override the scenario's base_url
--ui-url PATH\|URL where the Redline UI is mounted, for the printed link (overrides the scenario's ui_url)
--name TEXT run name
--store PATH store to write the run to (default .redline/redline.db)
--store-url URL write the run to a shared PostgreSQL store (postgresql://...)
--register-url URL register the run with the application over HTTP (needs accept_remote_runs there)
--token-file PATH file holding the Redline access token for --register-url (else REDLINE_TOKEN)
--no-store do not write to a store
--probe, --no-probe send (or skip) one tagged GET before the run to check the app records it. On by default with --store-url / --register-url, off with a file store
--require-recording stop the run when the probe request is not recorded (default: warn)
--probe-timeout 5s how long to wait for the probe trace
--json OUT also write the results as JSON
--fail-p95-ms X exit 1 if the run-wide p95 exceeds X ms
--fail-error-rate Y exit 1 if the error rate exceeds Y (0.01 or 1%)
--quiet, -q only print the final table
--ui-url URL the Redline UI address printed in the "See bottlenecks in the Redline UI at ..." line after the run. Default: the scenario's host plus the mount_path setting (from redline.toml or REDLINE_MOUNT_PATH), else /_redline

--rps, --ramp, --steps and --stages are mutually exclusive. redline load init writes scenarios; see Generating scenarios. A TOML scenario it writes ends with a commented-out example of the optional keys ([auth], [[flows]] with extract, expect, max_ms, think_s and own_connection): uncomment the lines you need and edit them.

Exit codes: 0 ok, 1 a --fail-* threshold was breached or the run failed, 2 usage or scenario error, 130 interrupted with Ctrl-C (the partial results are still saved).

Workers

The generator runs as several processes (asyncio and httpx in each), not threads, so that the Python GIL in the generator does not cap the rate it can offer or distort the latency it measures. Each worker sends per-second histograms to the parent. All workers follow the same precomputed plan from a shared start time, so step boundaries line up without any messaging. The number of workers never exceeds the target rate.

For a high rate, raise --workers up to your core count, leaving one for the app if it runs on the same machine. A generator on the same machine competes with the app for CPU; for numbers you trust, run it from another host.

Reading the results

A load run: steps, latency chart, the knee and the bottlenecks found under load A load run: steps, latency chart, the knee and the bottlenecks found under load

The step table

Column Meaning
target, achieved the offered rate, and what was actually completed per second
sent, ok, err requests started, successful, failed
drop arrivals that could not start because the in-flight cap was reached. Non-zero means the generator or the server's queue was saturated
p50, p95, p99, max latency, from the scheduled time
err% errors divided by completed requests

An error is a status outside expect_status, a timeout, or a connection failure; the final summary breaks them down (timeout x12, 503 x31).

The verdict is one word:

Verdict Meaning
healthy no knee in the tested range. Raise the top of the range to find it
saturated a knee after at least one good step. max ok rps is the last good step
failing the very first step is already the knee. Lower the starting rate
no data no complete step

Resources: which one ran out

The knee says when the system stopped keeping up and the bottleneck table says which query slowed; neither says whether the app CPU, the connection pool or memory was the limit. While a run that is registered in the app's store is sending it traffic (and only then), each app worker samples itself once a second: process CPU, resident memory, garbage-collection pauses, threads, and the SQLAlchemy pool (size, checked out, time spent waiting for a connection). Samples are stored with the run and its current step (turn it off with run_metrics = false; the production preset does). The run summary then carries resources (per step, average and maximum of each number) and a verdict in limiting_resource, which the CLI prints:

limiting resource: step 8: connection pool exhausted (5/5 checked out), wait time 40x the first step

The verdict looks at the knee step (else the last one) in this order: pool (every connection checked out and requests waiting for one), cpu (a worker above 85% of a core), gc (pauses of 10% of the time or more), else unknown. Memory that grew by 30% over the run is added as a note, never as the limit. GET api/runs/{id}/metrics returns the same.

Numbers from outside the process (a database or host monitor, a cloud metrics API) come in through a metric source: a function you write that returns {name: number} for a time range, called once per step after the run:

metric_sources = ["perf_monitors:database"]   # package.module:function
def database(start_epoch: float, end_epoch: float) -> dict[str, float]:
    return {"db_cpu_pct": query_my_monitor(start_epoch, end_epoch)}

They are stored beside the app's own samples and shown in resources. A source that raises is listed under metric_source_errors; it never fails the run. Sources are only read from a scenario file (they run your code), and a remote generator posts them to the app with POST api/runs/{id}/metrics. Database-side counters (active sessions, waits, blocking) are not sampled by Redline itself: a metric source is the place for them.

Bottlenecks

The Bottlenecks table in the UI answers "what got slower". It joins the traces tagged with the run, step by step, with their per-fingerprint and per-route summaries:

Item kind Compared
sql mean time per execution of each query, by step
route mean time per request of each endpoint, by step
other mean time per request that no span covers (the gap between the spans, see unattributed time), by step. Read from the run's 2000 latest requests; absent when every request is fully covered

Each item shows its mean and p95 at every step and a growth factor: the last step's mean divided by the first's (floored at 0.01 ms to avoid dividing by nothing). Items are sorted by growth, so the top row is the thing that degraded most as load rose. Click one to open a sample trace, with its callsite.

What a bottleneck usually means

Pattern Usually
One SQL statement's time grows 100x a missing index or a lock; run EXPLAIN on a sample
Every statement grows together; routes grow the database or its pool is saturated. Look for pool_wait spans (Transactions and locks)
SQL flat, routes grow the app itself: CPU, GIL, blocking in async, or a downstream call
The other row grows with the routes time redline cannot see: CPU, or a client with no span (wrap it)
dropped rises with flat server latency the generator is the limit. More workers, or another machine
Errors with no matching traces requests are rejected before the app records them (proxy, worker queue)

CI usage

--fail-p95-ms and --fail-error-rate turn a run into a gate. The exit code is 1 on a breach, with the reason printed:

# .github/workflows/perf.yml (excerpt)
- name: Start the app
  run: |
    python manage.py migrate
    python manage.py runserver 8000 &
    sleep 5
- name: Smoke load test
  run: |
    redline load scenario.toml --rps 30 --duration 30s \
      --fail-p95-ms 400 --fail-error-rate 1% \
      --json load-result.json --no-store
- uses: actions/upload-artifact@v4
  if: always()
  with:
    name: load-result
    path: load-result.json

Notes for stable CI numbers:

  • Shared CI runners are noisy. Use generous thresholds, or compare against a stored baseline rather than an absolute number. Use constant at a rate comfortably below the knee: the goal is to catch a regression, not to find capacity.
  • The gate checks the whole run, not each step.
  • --json writes the full per-step results for archiving. --no-store skips the SQLite file when there is no UI to view it in.

Starting a run from the UI

With load_from_ui = True the Load page has a form that starts a run against the app that serves the UI. It is off by default (403 load_disabled) and needs redline-core[load], and either a file-backed SQLite store or the shared PostgreSQL store (storage_url), which the background process reaches through the REDLINE_STORAGE_URL environment variable. On a shared store there are no pid files to tell a killed run from a live one, so stopping a run whose process is gone closes it as failed. It is also blocked by read_only (403 read_only) and the load feature switch (404 feature_disabled), and the production preset keeps it off. Turn it on only in environments where load is welcome. See Security.

Where the run goes. The request list can contain only paths (a single leading /; no scheme or host), so the form cannot aim the server at somebody else. The target is the base_url setting when you set it. Otherwise it is 127.0.0.1 on the port the server is listening on (ASGI scope["server"], WSGI SERVER_PORT), plus the script root; the Host header is never used, so a request cannot aim the run at another service on the machine. When the port is unknown (the app listens on a unix socket), or the app is not reachable on 127.0.0.1 (it listens on one specific interface, or behind a container port mapping), POST api/runs answers 400 invalid_body or the run fails to connect: set base_url:

# redline.toml
base_url = "http://127.0.0.1:8000"      # the application's own address

A base_url or workers key in the request body is ignored.

Limits. Runs started from the UI are capped more tightly than the CLI: at most one hour, 5 000 requests per second and 200 steps; the body needs a name, a non-empty requests list, and a profile with a mode (constant, ramp or steps), a positive duration_s and the rates that mode needs. A run goes through the same scenario validation as a file. It runs in a detached redline load process, writes into the same store, and is listed with status running, then done, stopped (you stopped it) or failed. The run's stored config has secret-looking header values, body keys and URL secrets masked (the raw scenario lives in a mode 0600 file that is deleted when the run ends).

The same actions are in the API: POST api/runs (202), POST api/runs/{id}/stop, DELETE api/runs/{id} (409 run_active while it runs) (HTTP API).

Generating scenarios

Writing a scenario by hand is fine for a handful of endpoints; for a real app, generate a starting point and edit it.

Source Command Notes
OpenAPI (FastAPI, Litestar, Django Ninja) redline load init --from-openapi URL_OR_FILE Path parameters get example values. Operations with required query or header parameters, and all non-GET operations, are written with weight = 0 so you opt in after reviewing
Captured traffic redline load init --from-traces Takes the busiest endpoints from your store (--top, --window), picks a concrete sample path for each, weights GETs by their share of traffic. Bodies are never copied
Django URLconf python manage.py redline_scenario [-o FILE] [--base-url URL] [--force] Every GET route; routes without parameters get weight = 1. A parameterised route (<int:pk>) is filled with a concrete path from a recent trace of that route, and left out when there is none. The admin namespace and Redline's own URLs are skipped. Django Ninja and DRF routes are included. Prints to stdout without -o
Flask url_map flask redline scenario [-o FILE] [--base-url URL] [--force] The same rule over the url_map (static files and Redline's own routes skipped). Default base URL http://127.0.0.1:5000

redline load init options:

Option Meaning
--from-openapi URL\|FILE an OpenAPI 3 or Swagger 2 document
--from-traces captured traffic in --store
--store PATH for --from-traces (default .redline/redline.db)
--window 24h how far back to look
--top 10 endpoints to keep
--include-writes also include POST/PUT/PATCH/DELETE (written with weight = 0)
--data-dir DIR with --from-traces: write each endpoint's distinct paths as CSV here and use them as zipf data sources
--stages RPS:DURATION,... write a stages profile into the scenario
--identities-file FILE, --identity-mode MODE add identities_file and identity_mode to the scenario
--base-url URL set base_url
-o, --out PATH output file; .toml or .json; - prints to stdout (default scenario.toml)
--force overwrite an existing file

The generator validates its own output, so a scenario it writes can be run. Write requests are always disabled by default: a load test that POSTs and DELETEs against a real database is something to choose deliberately.

Limits

  • It tests HTTP endpoints over the network, plus held streams and WebSocket connections (see Streams and WebSockets). It does not drive a browser: see Browser pages for the recipe.
  • Latency is as measured by the generator, including the network and the generator's own event loop. Distrust sub-millisecond numbers.
  • Correlated bottlenecks need the app to record the load; with strong sampling, or a store the app is not writing to, the table is empty.
  • Run records live in the Redline SQLite store and are subject to history retention.