---
title: "Performance at customer scale"
description: "Measured latency of the hot read routes and the scan ingest rate for one organization with up to 5,000 assets and 200,000 findings."
---

These are measurements of one build on one machine, not a capacity plan or a
promise. They exist so a customer can see what the product does with an estate
the size of theirs, and so a change that makes it slower is caught by a number
rather than by a complaint. Re-run them on your own hardware before sizing a
deployment; [Scaling](/deployment/scaling) explains what to scale.

## Latest run: 2026-11-14, after migration 175

Two changes, measured back to back against the commit before them on the same
machine, the same dataset and the same harness:

- **The overview** (`/stats`) read the open backlog twice per request, walking
  every open finding each time. It now reads `finding_open_counts`
  (migration 175): the same counts kept per asset, kind, severity, status and
  first-seen time by triggers on the findings table, read in one query.
- **Scan ingest** issued four statements per finding (a lock, an insert or
  update, an event, and in production two more for webhooks and
  notifications). It now applies a scan in chunks of 1,000 findings with a few
  set statements each, and asks once per scan whether anything in the
  organization subscribes to finding changes before announcing any.

| | |
|---|---|
| Builds | before: `47253b80`; after: the w25 ops branch (migration 175) |
| Dataset | one organization, **2,500** assets, **100,000** findings, seeded as below |
| Machine | 8 vCPU, shared with other build jobs running at a **load average of 23 to 51** throughout: every number here is several times what an idle host gives (the 2026-11-13 run, at lower load, measured the listings at 35-65 ms) |
| Harness | `TestLoadCustomerScale`, `TRUSTOWL_SCALE_ASSETS=2500`; two runs of each build with 8 clients, alternated, and one of each with 1 client |

| | Before | After |
|---|---|---|
| `GET /api/v1/stats` p50, 1 client | 195 ms | **51 ms** |
| `GET /api/v1/stats` p95, 1 client | 278 ms | 110 ms |
| `GET /api/v1/stats` p50, 8 clients (two runs each) | 685 ms, 1,120 ms | 200 ms, 202 ms |
| Ingest, 5,000 findings, first scan | 106 and 113 findings/s | **686 to 1,028 findings/s** |
| Ingest, 5,000 findings, rescan | 144 and 163 findings/s | **4,155 to 5,457 findings/s** |
| Ingest, 1 client run, first scan / rescan | 130 / 155 findings/s | 739 / 3,143 findings/s |

With one client the overview is now in line with the findings listings on the
same run (29-64 ms p50), where it was three to seven times slower than them.
With 8 clients on a host this busy every route queues for CPU, and the
overview sits with them (124-304 ms p50 for the listings in the same runs).

A 50,000-finding scan result that took about five minutes to land now takes
under a minute on this machine. The rows written are the same: the lifecycle
tests pass unchanged, and every event is still linked into the
organization's audit chain in the order the scan produced it.

Repository benchmarks, guarded by `make ci-perf-budget`:
`BenchmarkFindingIngestApplyScan` (1,000 findings) went from about 4.4 s to
1.2 s per op, and `BenchmarkOverviewCountsAtScale` (100,000 findings, 10,000
assets) reads the overview's backlog figures in 37 ms.

## Previous run: 2026-11-13, after migration 167

| | |
|---|---|
| Build | commit `f00432c1` (2026-11-13), migration 167 (the default-order index) applied |
| Dataset | one organization: **2,500** assets, **100,000** findings (40 per asset), half the dataset below and seeded the same way |
| Machine | a shared build host under load from other jobs; PostgreSQL 16 and Redis 7 in throwaway containers |
| Harness | the same test, `TestLoadCustomerScale`, run with `TRUSTOWL_SCALE_ASSETS=2500` |

| Route | p50 | p95 |
|---|---|---|
| `GET /api/v1/findings?limit=50` (default, severity order) | 65 ms | 123 ms |
| `GET /api/v1/findings?limit=50&order=recent` | 63 ms | 122 ms |
| `GET /api/v1/findings?limit=50&order=risk` | 62 ms | 121 ms |
| `GET /api/v1/findings?limit=50&severity=critical&status=open` | 47 ms | 110 ms |
| `GET /api/v1/findings?limit=50&q=pkg-12` | 52 ms | 145 ms |
| `GET /api/v1/findings?limit=50&asset_id=…` | 35 ms | 78 ms |
| `GET /api/v1/stats` | 264 ms | 341 ms |
| `GET /api/v1/assets/:id` | 30 ms | 87 ms |
| `GET /api/v1/assets?limit=50` | 79 ms | 150 ms |

Ingest of a 5,000-finding scan: 28.6 s on the first scan (175 findings/s) and
24.2 s on a rescan (206 findings/s). The overview (`/stats`) is now the slowest
read route, and ingest rate is unchanged: a 50,000-finding result takes about
five minutes to land.

The rest of this page is the earlier, larger run, taken **before** migration
167. Its default-order row (459 ms) is the cost that migration removed.

## What was measured (2026-11-11, before migration 167)

| | |
|---|---|
| Build | commit `ad4a1ea3` (2026-11-11), the asset-list and overview changes below included |
| Dataset | one organization: **5,000** container-image assets, one completed scan each, **200,000** findings (40 per asset). 70% open, 20% resolved, 5% triaged, 5% suppressed; 5% critical, 20% high, 40% medium, 35% low; 3,000 distinct CVE identifiers and 400 distinct packages shared across the estate. Seeded in bulk SQL, then `ANALYZE` |
| Machine | 8 vCPU AMD EPYC 7B12, 31 GB RAM, shared with other build jobs (load average 2-10 during the runs) |
| Database | PostgreSQL 16.15 (`postgres:16-alpine`), data directory on a RAM disk, default settings except what the image sets (`shared_buffers` 256 MB) |
| Client | 8 concurrent clients for 10 s per route, in the same process as the API: the real router, authenticator, handlers and database, no network or TLS |
| Harness | `backend/internal/api/load_scale_test.go`, using the driver in `load_test.go` |

Because the API and the database share one busy machine, read the numbers as
**relative**: the same run, before and after a change, on the same host. Runs a
few minutes apart differed by up to 2x on routes no change touched.

## Read routes (2026-11-11)

Latency per request, 8 concurrent clients, all responses `200`.

| Route | What the console uses it for | p50 | p95 |
|---|---|---|---|
| `GET /api/v1/findings?limit=50` | the findings backlog, default (severity) order, before migration 167 | 459 ms | 934 ms |
| `GET /api/v1/findings?limit=50&order=recent` | newest first | 59 ms | 110 ms |
| `GET /api/v1/findings?limit=50&order=risk` | risk order | 61 ms | 113 ms |
| `GET /api/v1/findings?limit=50&severity=critical&status=open` | a filtered backlog | 79 ms | 151 ms |
| `GET /api/v1/findings?limit=50&q=pkg-12` | search | 89 ms | 150 ms |
| `GET /api/v1/findings?limit=50&asset_id=…` | an asset's findings tab | 36 ms | 82 ms |
| `GET /api/v1/stats` | the overview | 501 ms | 718 ms |
| `GET /api/v1/assets/:id` | the asset page | 29 ms | 81 ms |
| `GET /api/v1/assets?limit=50` | the asset inventory | 73 ms | 134 ms |

## Scan ingest (2026-11-11)

One image's scan result applied through the same store the scan worker uses
(`FindingWriteStore.ApplyScan`), in one transaction, with the lifecycle event
and its audit hash chain written per finding.

| Result | Time | Rate |
|---|---|---|
| 5,000 findings, first scan of the image (all created) | 33.1 s | 151 findings/s |
| The same 5,000 again, a rescan (all still open) | 27.9 s | 179 findings/s |

Most of the time is in the database: each finding's event row is linked into
the organization's tamper-evident audit chain, which is per-organization and
therefore serial. The run uses 5,000 findings to make that cost visible; the
time grows with the number of findings in the result.

## What these runs changed

Two read paths scanned the whole open backlog on every request:

- **The asset inventory** counted open findings by severity for *every* asset
  in the organization, and then showed 50. It now counts only for the assets on
  the page. The query went from 48.7 ms to 4.0 ms (`EXPLAIN ANALYZE`, 200,000
  findings), the repository benchmark `BenchmarkAssetListAtScale` from 71.8 to
  12.3 ms per page, and the route under load from 349 ms to 73 ms at p50.
- **The overview** grouped the open backlog by severity and again by kind, asset
  kind and severity. The severity counts are now summed from the second, which
  removes one of its three backlog-wide aggregates (31 of about 160 ms of
  database time per request). The load runs cannot separate that from the
  machine's noise.

The runs also found that the API specification did not list `risk` as a page
order, so every risk-ordered findings page failed a client that validates
responses. The specification now lists it.

## The default backlog order

The findings backlog's default order (severity, then last seen) was the slowest
route measured: about 66 ms of database time per page at 200,000 findings,
because no index matched that order and PostgreSQL sorted the organization's
findings for every page. Migration 167 adds an index on the order expression;
with it the same query took 0.6 ms in the same database. The 2026-11-11 tables
were taken before that migration; in the 2026-11-13 run at the top of this page
the default order is 65 ms at p50, in line with the other orders.

## Reproduce

```bash
export TEST_DATABASE_URL='postgres://…'   # a database the test may truncate
export TEST_REDIS_URL='redis://…/2'
TRUSTOWL_LOAD=1 GOEXPERIMENT=jsonv2 \
  go test -count=1 -timeout 50m -run TestLoadCustomerScale -v ./internal/api/
```

| Variable | Default | |
|---|---|---|
| `TRUSTOWL_SCALE_ASSETS` | `5000` | assets in the organization |
| `TRUSTOWL_SCALE_FINDINGS_PER_ASSET` | `40` | findings per asset |
| `TRUSTOWL_SCALE_INGEST_FINDINGS` | `5000` | findings in the ingested scan |
| `TRUSTOWL_LOAD_WORKERS` | `8` | concurrent clients |
| `TRUSTOWL_LOAD_DURATION` | `10s` | per route |

Run it from `backend/`. Seeding takes about 40 seconds; the whole run about
three minutes.
