Skip to main content

Load testing the services

What each deployable service can take, how to measure it, and what the numbers mean. The tool is tests/load (ghb-load, Go, no external dependency); the runner is scripts/load-test.sh (make load-test). The capacity formulas and the worker's run-time model are in CAPACITY_MODEL.md.

What is load-tested​

Every service is an HTTP server behind the Caddy gateway, so every one of them can be loaded with the same tool:

ServicePort in the compose stackRoutes under loadLimits the service enforces
identity (Go)gateway :8080/api/me, the agent link flow, personal tokens100/min per address on /api (300/min behind a trusted proxy), 60 token failures/min per address, 10 link starts/min per address
runs (Go)gateway :8080/v1/runs, /v1/runs/{id}/{logs,results,progress,complete}600/min per agent, 1,200/min per account, batches of 500 results or logs, 2 MiB bodies
insights (Go)gateway :8080/api/dashboard/stats, /api/backups, /api/analytics/*, /api/repos, /api/logs, /api/metrics, /api/logs/streamin-flight limit DB_MAX_CONNS x 4 with a 2 s wait, then 503 SERVICE_BUSY; 10 streams per account, 500 per process; 300/min per account
MCP server (Go):8090/mcp (streamable HTTP)120 tool calls/min per account; 5 s per call to the API
Observatory (FastAPI):8000/health, /ready, /api/models, /api/tools, /api/embedding-modelsone uvicorn process; 8 concurrent LLM calls, 2 chat turns per account, 4 tool calls per model message
dashboard (Next.js):3000/api/health; its pages call insights through /api/proxy/backupnone of its own; the gateway's per-address limit applies to the forwarded address

Not loaded, and why:

  • The Observatory's chat and search routes call OpenRouter. Loading them needs a fake OpenRouter server; until one exists they are measured per turn, not per second.
  • The worker is a command, not a server. Its run time is modelled, not loaded: see the run-time model in CAPACITY_MODEL.md and make estimate.
  • Postgres itself. The services' own limits (connections per service, statement timeouts of 2 minutes, lock timeouts of 30 s) are what a load test reaches first; the database's saturation shows as SERVICE_BUSY answers and rising p95 in the read and agents scenarios.

Running it​

The stack is the compose stack of make smoke (docker-compose.yml: the five API services behind Caddy, the Observatory, the dashboard, the MCP server, Postgres with pgvector), started with its four HTTP ports on loopback (SMOKE_PUBLISH_PORTS=1) and sign-up open (SIGNUP_MODE=open). The owner's account is account 1; the load tool signs its session with the stack's JWT_SECRET, exactly as a password login would, and creates the other accounts through identity's internal route with INTERNAL_SECRET.

Accounts matter because the API limits per account: 300 calls a minute on /api and 1,200 on /v1. One account can therefore load insights at 5 calls/s and runs at 20 calls/s, no more; the read and agents scenarios pace themselves just under the allowance of the accounts they act as, and spread the load over them. Loading a service harder means more accounts (-accounts), not more callers: with more callers the limiter answers, not the service.

# Start the stack, run every scenario at the smoke profile, stop the stack.
LOAD_STACK=compose make load-test

# A stack that is already running, with its secret.
JWT_SECRET=... make load-test PROFILE=baseline
JWT_SECRET=... make load-test PROFILE=stress SCENARIOS="read agents streams"

# One scenario by hand, against another host.
go run ./tests/load/cmd/ghb-load read \
-target https://api.example.test -jwt-secret "$JWT_SECRET" \
-rate 50 -concurrency 64 -duration 2m -p95-ms 300 -max-error-rate 0.01 -out /tmp/load

Profiles:

ProfileWindowCallersAccountsPurpose
smoke20 s82 accounts, 2 agentsevery scenario runs and answers; no thresholds; fits a pull request
baseline2 min328 accounts, 8 agentsthe numbers recorded below; p95 under 300 ms and under 1% failures on health, read, observatory and agents
stress5 min12816 accounts, 16 agentsuntil something gives: which limit, at what rate, with what latency

Results go to tests/load/results/<timestamp>-<sha>/ (summary.md and a JSON per scenario); the directory is git-ignored. The exit status is 2 when a threshold broke, so a profile can gate a build.

The CI does not run load tests on every push: they need the whole stack and minutes of a runner. Run them before a release, after a change to a limit or a pool size, and when the deployment's machine changes.

Scenarios​

health: a closed loop over every service's liveness route. The ceiling of the cheapest route is the most calls a service can answer at all on the machine; everything else is slower. Labels show each service apart.

read: the reads the dashboard's pages make, with the accounts' sessions in turn, through the gateway to insights. Without -rate it runs an open loop at 4.5 calls/s per account, just under the 300/min allowance; a higher -rate measures the limiter instead. Watch three things: the p95, the 503 count (the in-flight limit, DB_MAX_CONNS x 4 per service) and late ticks (the arrival rate the target could not keep). On an empty stack the two /latest routes answer 404, which the scenario expects.

agents: linked workers, one per account by default, each cycling the run protocol: start a run, send -log-lines log lines in batches of 100, -repos results in batches of 500, complete with a summary and telemetry. One protocol step per call, so every step has its own latency and status; without -rate the steps are paced just under the allowance, which is the smaller of 10 calls/s per agent (600/min) and 20 calls/s per account (1,200/min): with one agent per account, 9 calls/s per agent. A run is five calls (start, two log batches, results, complete), so one agent reports at most two runs a second; past that the limiter answers 429. An account runs one backup at a time (the run lease), so more agents than accounts meet 409 LEASE_HELD, which the scenario counts apart and waits on, as a worker does. Linking is limited to 10 starts a minute per address; the tool paces links and caches the tokens in tests/load/results/agents-cache.json for the next run against the same stack.

limits: the owner's session calls GET /api/me at 10/s. After 300 calls, 30 s in, the per-account limit answers 429; the scenario counts them and whether Retry-After came with them. 429 is the expected answer here, not a failure. There is no warmup, and the runner waits a minute after the scenarios that spend the owner's budget, so the count of calls before the first 429 is the limit itself.

streams: K callers each hold one GET /api/logs/stream open for the window. The API allows 10 per account and 500 per process; the eleventh caller is refused (429 or 503), which the scenario expects.

observatory: the Observatory's public routes in a closed loop. One uvicorn process answers them; the p95 at 32 callers is the cost of the Python stack itself. /ready answers 503 until an OpenRouter key is set (the smoke stack has none), which the scenario expects.

mcp: initialize once per caller, then tools/list, with a personal token the scenario mints from the session. The server allows 120 tool calls per minute per account.

Reading the numbers​

  • A p95 that climbs with the caller count while calls/s stays flat means the service is saturated: more callers only queue. The ceiling is the calls/s where that starts.
  • 503 SERVICE_BUSY from /api is the in-flight limit, not an outage. It scales with DB_MAX_CONNS (4 per connection); raising it moves the pressure to Postgres.
  • Late ticks in an open loop mean the chosen rate is above what the target answers with the allowed concurrency; the measured latency then describes a saturated target, not a healthy one.
  • The compose stack on a laptop measures the code, not production: the laptop's CPUs, disk and memory are not the server's. Run the baseline on the deployment itself for capacity planning (scripts/load-test.sh against GHB_LOAD_TARGET=https://api.<host>).

Measured​

Record each baseline here with the commit, the machine and the stack it ran on, from tests/load/results/<run>/summary.md. A row is a measurement, never an estimate.

DateCommitMachineScenarioCalls/sp50 msp95 msFailedNotes
2026-10-2146bc816laptop, 12 CPUs, 14 GiB, compose stackhealth, 32 callers2,0461.4640gateway 1.0/1.4 ms, MCP 0.4/0.6 ms, Observatory 3.3/15 ms, dashboard /api/health 51/94 ms (p50/p95)
2026-10-2146bc816sameobservatory, 8 callers160251670/health, /api/tools, the catalogues 21-25 ms p50, 33-37 ms p95; /ready 148/210 ms answering 503 (no OpenRouter key). At 32 callers the same routes queue to 83 ms p50 and 149 ms p95: one uvicorn process
2026-10-2146bc816sameread, 8 accounts at 36/s363.27.70every insights read under 12 ms p95; /api/repos the slowest (7.5/11.3 ms); the per-account limit, not insights, caps the rate
2026-10-2146bc816samestreams, 12 callers12 streams1419010 streams held for the window, the 11th and 12th refused with 429, as designed
2026-10-2146bc816samelimits, 10/s for 45 s102.12.50exactly 300 answers of 200, then 149 of 429 every one with Retry-After
2026-10-2146bc816sameagents, 8 agents over 8 accounts at 72/s729.72501,728 runs in 2 min (14/s): start 6/27 ms, a batch of 100 log lines 10/22 ms, a batch of 50 results 17/30 ms, complete 6/15 ms (p50/p95). The same run at 144/s (above the 600/min per agent) answered 429 to 44% of the calls, every one on the start