Identity plane split, plan I2g: the capacity test and production sizing (epic &132)
Status: Done (2026-10-07) — !1576
Epic: &132 (stage I2 of &130)
Issues: #2752 (w3), #2753 (w5), #2754 (w3), #2755 (w5), #2756 (w5), #2757 (w3), #2758 (w3); the recorded run’s findings #2759 (G1), #2760 (G6) and the #1303 growth note
MR: feat/identity-capacity: U1–U7 in order, titled "canopy-identity capacity test and production sizing (#2752 … #2758)".
The seven issues ship as one MR under the maintainer’s one-MR-per-related-group ruling, one commit per issue: the settings and the instrument exist for the harness, and the harness’s record closes the plan, so no unit ships value alone. U1’s commit adds this page and its nav entry: the group Identity Plane Split (epic &130) holding * Identity plane split, plan I2g — the capacity test and production sizing (epic &132), placed just above ** Completed Plans Archive in docs/modules/ROOT/nav.adoc. U7’s commit closed the plan.
This is a Design + Scope plan. GitLab owns tracking. The plan freezes when U1 starts. "Plan I3" always means the stage; P1–P10 are this plan’s decisions and G1–G7 its gates.
Context
ADR-049 D2 answers option 3’s latency objection with "a capacity test runs before the cut-over", and reopen trigger 1 ("issuance load degrades canopy-security’s other work") names no metric. Plans I2a, I2d and I2f left production sizing here: the issuer pool, the per-IP limit, the per-client defaults, the native and attempt budgets.
In the tree today:
-
No load model, gate or baseline exists. The one measured auth number is today’s Keycloak exchange, p99 13 ms over 170 live exchanges (
crates/canopy-auth/src/token_exchanger.rs); the deployment guide’s sizing is "starting points, not measurements". -
I3 multiplies the issuer’s rate. D3’s routing rule (Amendment 4 B4) makes every call inside a worker’s request on that user’s data a delegation, reads included, per (request, target), reused within the request only (ruling R4). Today only writes exchange at Keycloak.
-
Limits would refuse I3. The token, revocation and both device routes share one per-IP limiter of 120 a minute (
TOKEN_RATE_LIMIT_RPM, a const inidentity/token_endpoint.rs), process-local and keyed by peer IP (canopy_api::apply_rate_limit); canopy-web calls from a few pod addresses, so even UAT exceeds it. The per-client default, 6000 a minute per replica (identity/clients.rs), would refuse canopy-web at the design load too. -
Pool and writer. The issuer pool is a 22-connection const with reasoned shares (
identity/registry.rs). The issuance-log writer commits at most 32 rows per batch after a 10 ms gather window, and every system and delegation answer waits for it (identity/issuance_log.rs). The log grows until #1303 sets retention (Amendment 3 A5). -
Observability. Counters only on the token routes; no request-latency metric anywhere; the per-IP limiter’s 429s are uncounted.
-
Tooling. The devstack’s canopy-security has no clients file or upstream profile and builds at opt-level 0, so a k6 run through the edge cannot measure the issuer.
cargo xtask perf chain-drainandchain-verifydrive real code paths on an ephemeral schema with a pinned method (xtask/src/cmd/perf.rs); xtask already depends on canopy-security, canopy-auth, canopy-signing, canopy-db and canopy-test-lib. canopy-security’s integration tests (tests/identity_delegation_test.rs,tests/identity_native_test.rs) wire a productionTokenEndpointin process. The devstack Keycloak has RFC 8693 exchange enabled (devstack/keycloak/canopy-realm.json,canopy-web-exchanger).
Scope
In scope: U1–U7 below.
Out of scope:
-
plan I3: canopy-web’s senders; sharing one request’s
DelegationCacheacross a page’s concurrent panels (P1’s fan-out assumes it); overwritingX-Forwarded-Forat the edge; forwarding the public routes; -
a load test of a deployed environment (the guide tells a deployment how to re-run with its own model);
-
the native grants and the device flow in the mix (under 0.1/s, each a delegation’s work) and upstream latency (the mock answers locally; F9 budgets the real one);
-
code changes a failed gate calls for, the pool’s default included (filed against &133);
-
issuance-log retention or archival (#1303); a Redis-backed limiter (D2 forbids it); any change to the 64-key cap.
Design
Decisions (recorded in ADR-049 Amendment 10, which lands with U1)
| # | Decision |
|---|---|
P1 |
The design load model. I3’s design point is the busy hour of Georgia’s statewide workforce on canopy (below); the peak is twice it. Every assumption is a |
P2 |
Per-IP limits are a backstop. Authenticated callers are bounded by their per-client budgets (G10, N9); anonymous internet traffic by canopy-web’s edge limit on the routes it forwards (D2). The token, revocation and device-verification routes take the setting |
P3 |
The issuer pool is a setting, |
P4 |
Per-client budgets. The 6000 default stays: it covers every client whose peak over R − 1 replicas is under 100/s, all but canopy-web and the busiest onward caller (canopy-eligibility, taken to carry all onward traffic). Those two entries are sized by formula: at R = 2, 60 000 and 18 000. canopy-cli’s 6000 stays (under 1/s). The attempt budget (N2), slow_down (N5) and the admin limit (60) are security bounds and stay. |
P5 |
Latency by grant. |
P6 |
The capacity harness, |
P7 |
Reopen trigger 1, made measurable. Issuance load degrades canopy-security’s other work when (a) G4 fails at the design point in a recorded run, or (b) in production, canopy-security’s |
P8 |
Today’s path, side by side, informational only. The harness drives the devstack Keycloak’s |
P9 |
Gates decide; records follow. G1–G7, each judged on the median of three repetitions, every repetition recorded. A recorded run’s gate table and the sizing it yields (replicas and vCPU per replica; Postgres commits, WAL and connections; issuance-log growth) land in Amendment 10’s as-built and the guide, whose canopy-security sizing becomes measured. A failed gate does not grow this plan: it is recorded and filed as an issue blocking epic &133. |
P10 |
Two bounds, documented. The key cap (64): published keys ≈ 2R + restarts in the last 6 h 12 m that followed a replica’s first rotation + 2 × restarts in the last 22 minutes; the guide gives the envelope per R and treats a replica restarting about every 10 minutes as an incident. The issuance log: measured bytes per row × the model’s rows a day against the 3-year audit floor ( |
The load model (P1)
| Assumption (flag) | Design | Basis |
|---|---|---|
|
3000 |
Georgia’s eligibility workforce across I3’s programs (caseworkers, supervisors, call centre, clerical); UAT 150 |
|
3 |
pages, htmx fragments and writes, one every 20 s |
|
3 |
case pages reach 4–6 services, fragments 1–2; R4 reuse removes repeats |
|
0.3 |
eligibility’s orchestration; applications to persons |
|
300 |
a 5-minute upstream access token drives re-federation (D6 caps it at 900) |
|
5, 2, 1 |
half the workforce signing in over 5 minutes; system tokens cached 300 s per (client, purpose) per pod |
|
2 |
minute-scale bursts within the busy hour |
| Fleet-wide rate | Formula | Design | Peak |
|---|---|---|---|
delegation, session form |
workers × requests × fanout / 60 |
450/s |
900/s |
delegation, onward |
onward × session form |
135/s |
270/s |
federation renewal; open |
workers / renew-seconds; opens |
10/s; 5/s |
20/s; 10/s |
revocation; client credentials |
logouts; system |
2/s; 1/s |
4/s; 2/s |
total |
≈ 600/s |
≈ 1200/s |
Sizing at the peak with R replicas, P canopy-web pods and canopy-web’s rate web (session form + federation + revocation = 934/s):
-
the per-IP setting ≥ 60·web / (P·max(R − 1, 1)): 28 020 at P = R = 2, hence 30 000;
-
canopy-web’s
rate_limit_rpm≥ 60·web / max(R − 1, 1): 56 040, hence 60 000; -
the busiest onward caller’s ≥ 60·onward / max(R − 1, 1): 16 200, hence 18 000.
UAT is a twentieth of the design point; every default holds there.
Gates (P9)
| # | Cell | Holds when |
|---|---|---|
G1 |
|
p99 ≤ 50 ms for each delegation form, client credentials and revocation; ≤ 100 ms for federation open and renewal |
G2 |
|
no 429, no 5xx; ≥ 99.5 % of scheduled requests answered within the window |
G3 |
|
p99 ≤ 2 × G1’s; no 429; 5xx ≤ 0.01 % |
G4 |
|
audit append p99 ≤ max(1.2 × idle p99, idle p99 + 2 ms); appends achieved ≥ 99.5 % of offered |
G5 |
|
each replica’s peak RSS ≤ 192 MiB (¾ of the guide’s 256 MB) |
G6 |
|
the issuer pool below its ceiling at every 1 s sample; expired jti rows at the window’s end ≤ one sweep interval’s inserts |
G7 |
every cell |
release build; generator lag p99 ≤ 5 ms; host CPU ≤ 80 %; the in-flight cap never hit. Otherwise the cell is INVALID, neither pass nor fail |
The saturation cell (one replica) has no gate. It yields the per-replica knee, CPU seconds per request and the bottleneck (replica CPU, pool ceiling, commit time), and, at P2’s and P4’s settings, whether one replica carries the peak without a 429 (the R − 1 case for R = 2).
The harness (P6)
cargo xtask perf identity (the driver) and the hidden perf identity-replica (one replica), in xtask/src/cmd/perf/identity/, beside chain-drain.
-
Substrate. The driver creates an
EphemeralSchemaon the devstack security database carrying every canopy-security migration (asservices/canopy-security/tests/common/issuer.rs::security_schemabuilds one), a mirror login ofcanopy_identity_issueron it (mirror_login, moved to canopy-test-lib), aMockIssuerupstream under thekanidmprofile, and fresh ES256 keys for canopy-web, canopy-eligibility, canopy-applications and canopy-portal, written with P4’s budgets into a run-scopedidentity-clients.yamlundertest-results/perf/identity/. Teardown of replicas, login and schema is awaited on every exit path. -
Replicas. Each is the release xtask binary re-executed (
std::env::current_exe) as its own process on a 2-worker runtime (--replica-threads), with production JSON logging to a per-replica file and anopentelemetry_sdkmeter provider on aManualReader, which the report reads.-
The issuer pool comes from
connect_issuer_pooloverEnvSecretProvider, as in production (thedb-poolsgate applies). The driver sets the child’sCANOPY_SECURITYIDENTITY_DATABASE_URLto the mirror login (passwordcanopy_test_lib::db::DISPOSABLE_LOGIN_PASSWORD) at acanopy_test_lib::DelayRelaythe driver runs per replica (--db-rtt-ms, 1 in recorded runs), with the schema assearch_pathin the URL’soptionsparameter (canopy-db’sconnect_optionsappends its session settings to it). It setsCANOPY_PERFAUDIT_DATABASE_URLto the schema owner’s in the same form, directly at Postgres, for the audit probe (U6). -
TokenEndpointPartsis built from the production types asmain.rsbuilds it; the key ring runs onSystemClock(the first key rotates under load), with the jti and session sweepers. -
token_endpoint::routerat P2’s settings and the JWKS route sit insidecanopy_api::outer_stack(the layersApiServer::routerapplies fromDefaultBodyLimitthroughapi_version_layer, extracted), served on127.0.0.1:0withinto_make_service_with_connect_info::<SocketAddr>so the limiters see each source’s address. -
The replica prints
READY <addr>once its key signs, servesGET /perf/report(pool samples, the writer’s and P5’s histograms, the audit probe’s latencies), and exits when stdin closes.
-
-
Load. Open loop: each grant stream has Poisson arrivals at the model’s rate, seeded by
--seed(printed); latency is measured from the scheduled start; the in-flight cap is 10 000.-
Production senders:
ClientAssertionMintersigns every assertion;DelegationTokenSource(a fresh request cache per call) sends both delegation forms, onward canopy-eligibility to canopy-applications presenting a canopy-eligibility token minted within the last 200 s; client credentials (canopy-portal), federation open and renewal (MockIssuer id_tokens; every session renewed every 300 s) and revocation go as forms, as the integration tests post them. -
Each source is bound to its own loopback address (canopy-web pods 127.0.1.1–3, canopy-eligibility 127.0.2.1–2, canopy-portal 127.0.3.1–2), so the per-IP limiters run at production settings: the delegation sources through a new
canopy_auth::IdentityHttpClient::bound_to(IpAddr)(U5;new()'s timeouts and no-redirect policy pluslocal_address), the forms through reqwest clients withlocal_address. Requests alternate between replicas. Setup opens--workerssessions at 50/s.
-
-
Cells. 3 repetitions × (30 s warmup + 120 s window) unless stated:
idle-probe(audit probe only);design(600/s, probe on);peak(1200/s);saturation(one replica, 300/s rising 150/s per 60 s window until delegation p99 > 250 ms, errors > 0.1 % or achieved < 95 %; one repetition);keycloak(P8, one repetition).--quick: one repetition ofdesignat a tenth of the rates, 100 workers, 5 s warmup, 15 s window, no verdicts. -
Measured per cell and repetition. Per grant: offered and achieved rate, p50, p95, p99 and max, status mix. Per replica: CPU seconds per request (
/proc/<pid>/statutime + stime) and peakVmRSSat 1 Hz. Generator: host CPU (xtask/src/sysmon.rs's/proc/statparser) and lag. Pool and writer: samples at the ceiling, commit p99, batch rows, expired jti rows. Postgres: commits and WAL bytes (pg_stat_database,pg_stat_wal), a checkpoint in the window flagged (pg_stat_checkpointer), issuance-log bytes per row (Δ`pg_total_relation_size` / rows added, as the schema owner). -
Output. chain-verify’s gate table (PASS, FAIL, UNSUPPORTED, plus INVALID for G7) and
test-results/perf/identity-<UTC>.json(host CPU model, threads, storage and PostgreSQL version; git SHA; seed; flags; every measurement). A failed gate exits non-zero.
Conventions every unit follows
-
Harness code keeps the workspace lints (typed errors, functions of at most 40 lines, overflow-safe arithmetic). Its pure parts (model arithmetic, schedule, percentiles,
/procparsers, verdicts) have unit tests and proptests; devstack-dependent parts run under--quickin verification, never in the battery (xtask is the perf home). -
Every unit ships its
CHANGELOG.adocbullet and its surface’s canonical page; numbers in docs come from a recorded run, its host named.
Units
-
U1 (w3) —
docs(adr): record the identity capacity model in ADR-049 (#2752). Amendment 10 (P1–P10, the model, the formulas, the gates); inline pointers from D2’s capacity sentence and reopen trigger 1. Docs: ADR-049, this page and its nav entry. -
U2 (w5) —
feat(security): make token limits and issuer pool settings (#2753). P2, P3:identity_token_rate_limit_rpmandidentity_db_max_connectionsinconfig.rswith typed accessors refusing the boot by name;token_endpoint::routerputs device authorization on its own limiter and the other three routes on the setting,no_storeoutside both;issuer_pool_opts,connect_issuer_poolandidentity::boottake the size; the two consts removed and the pool-shares comment restated against the floor. Tests: defaults and bounds (0, 11, 65 and 600 001 refused); over loopback from 127.0.0.1 and 127.0.0.2, the 31st device authorization from one address is a 429 while that address’s token route still answers and the other address is unaffected; the pool’s ceiling equals the setting. Docs:configuration-reference.adoc; every page stating the 120-a-minute limit (api/canopy-security.adoc,security.adoc,authorization-inventory.adoc);deployment-guide.adoc(the connection budget). -
U3 (w3) —
feat(security): measure token route latency by grant (#2754). P5: the layer, the response extension, the instrument intoken_endpoint/metrics.rs;opentelemetry_sdkwithtestingas a dev-dependency (canopy-db’s in-memory exporter pattern, one process per test under nextest). Tests: a delegation recordsdelegation/ok; a refused client-credentials formclient_credentials/refused; the limiter’s 429none/limited; a 503unavailable; thegrantvalues are exactly the log’s vocabulary plusnone. Docs:deployment-guide.adoc(the instrument; p99 by grant as an alerting start),security-operations.adoc. -
U4 (w5) —
chore(xtask): add the identity capacity replica process (#2755). P6’s substrate and replicas:perf identitysets up the substrate, starts the replicas, waits for eachREADY, reads each report and tears everything down (no load yet); the hiddenperf identity-replica;mirror_loginmoved tocanopy_test_lib::dbwith a typed error (thiserror: reading the role’s privileges, the role granted nothing, a grant failing), the tests'common/issuer.rsthen calling it;canopy_test_lib::DelayRelaybesideStallingRelay;canopy_api::outer_stackextracted fromApiServer::router(which then calls it);GET /perf/report. New xtask dependencies:axum,canopy-api,canopy-secrets,opentelemetryandopentelemetry_sdk(workspace versions). Tests: the relay delivers every byte in order and none sooner than half the RTT each way; the report round-trips its JSON; canopy-api’s router tests pass unchanged over the extraction. Docs:tooling/xtask-catalog.adoc. Erratum (2026-10-07): the replica’s meter provider is a periodic reader flushed on demand, through an exporter that keeps the latest export’s histogram points, since the SDK’s manual reader is behind an experimental feature;drop_loginmoves besidemirror_login, and a failedmirror_logindrops its login; xtask also gainstracing,tracing-subscriberandurl;outer_stackrefuses a wildcard CORS origin with a typedCorsWildcardRefused. Erratum (2026-10-07, after the recorded run): the replica installs no log subscriber, since xtask is a tool that writes nothing it traces (ADR-041 A’s inventory); its stderr file keeps its warnings. The recorded run’s replicas wrote JSON logs, so its CPU per request includes logging. -
U5 (w5) —
chore(xtask): drive the identity capacity cells and gates (#2756). P6’s load: model flags, session setup, the open-loop schedule, senders and sources, thedesign,peakandsaturationcells, every measurement, the gate table with INVALID, the JSON,--quick; in canopy-auth,IdentityHttpClient::bound_to(IpAddr). Tests: abound_to(127.0.0.2)request reaches aConnectInfoserver from 127.0.0.2 and, likenew()'s client, does not follow a 302; P1’s derived rates from the defaults; a seeded schedule reproducible, its mean rate within 2 % over 105 arrivals; percentiles (proptest: within range, monotone in the quantile); the/proc/<pid>/statparser (proptest: never panics, plus fixtures); verdicts on the median of three and INVALID per G7. Docs:tooling/xtask-catalog.adoc. Erratum (2026-10-07): each repetition runs on a fresh substrate and fleet; each saturation step sends a 10 s warmup before its 60 s window; the session-form delegations rotate over canopy-web’s compiled delegation targets;--cells,--reps,--warmup-secsand--window-secsexpose the pinned method. -
U6 (w3) —
chore(xtask): probe audit isolation and the Keycloak path (#2757). P7, P8:perf/identity/audit_probe.rs, run in each replica at--audit-rate(Poisson, the run’s seed): syntheticParsedAuditEvents (a fixed perfevent_typeandsource_service, a freshEventEnvelopeId, no PII) throughstore::insert_audit_eventon a 10-connection pool as the schema owner, each call timed from its scheduled start; theidle-probecell and G4; thekeycloakcell against the devstack Keycloak’s token endpoint. Tests: G4’s verdict at and around its noise floor (the 2 ms and the 1.2 × arms each deciding) and on an achieved rate below 99.5 %; the probe itself runs under--quick. Docs:tooling/xtask-catalog.adoc. Erratum (2026-10-07):--audit-rateis the fleet’s, split evenly between the replicas, so the appends match the model’s one a minute per worker;idle-probeopens no sessions; thekeycloakcell exchanges a seeded worker’s password-grant token forcanopy-tanfand mints the portal’saud-canopy-applicationstoken, asidentity verify's probes do. -
U7 (w3) —
docs(security): record measured identity capacity and sizing (#2758). The recorded run. The guide’s canopy-security sizing becomes measured on the named host: replicas and vCPU, the limits table and formulas, Postgres commits, WAL and connections, P10’s bounds, and how an operator re-runs the harness. Amendment 10’s as-built record (the gate table, the outputs). Each failed gate and P10’s growth finding filed as issues. The plan closes here: StatusDone (YYYY-MM-DD) — !N; the page moved todocs/modules/ROOT/pages/plans/archive/, every xref following; the nav group removed and the archived entry appended, suffixed— DONE YYYY-MM-DD;cargo xtask plan-lint --donewith one--allow-openper still-open issue the page cites (the seven, #1303, each filed gate issue). Erratum (2026-10-07): the recorded run failed G1 (delegation p99 55 ms) and G6 (the pool at its ceiling at the peak), filed as #2759 and #2760 against &133; its log-growth finding went to #1303 as a comment, and #1304 (cited by P7) is open too.
Risks the method carries
-
One host. Generator, replicas and Postgres share CPU; G7 marks a crowded cell INVALID; replicas are their own processes on 2 worker threads each, so CPU and RSS stay attributable.
-
Build profile. Devstack images build at opt-level 0, so replicas come from the release xtask; under a debug build every cell is INVALID.
-
Commit variance. fsync stalls and checkpoints dominate tails: medians of three, a checkpoint flag, the writer’s commit histogram, an idle host. Loopback understates production RTT and synchronous replication, so recorded runs add 1 ms.
-
Replica arithmetic. Per-replica limits multiply with replicas and shrink in total when one is lost; P1 sizes for R − 1. Pinned connections can skew replicas beyond the harness’s alternation.
-
Fan-out. It holds only if canopy-web shares a request’s delegation cache across a page’s concurrent panels (I3).
-
Keying. A mesh sidecar presenting every caller as one loopback peer turns the per-IP setting into a fleet-wide cap; a canopy-web that appends to
X-Forwarded-Forlets a client choose its key. The guide states both. -
The gather window. The writer’s 10 ms window floors every system and delegation answer while batches are sparse (about 3 rows per window per replica at the design point). If G1 fails, this is the first lever, filed per P9.
Maintainer calls embedded in the decisions
-
P1’s design point (3000 workers, 3 requests a minute, fan-out 3, onward 0.3, renewal every 300 s).
-
G1–G6’s values, and Keycloak informational only (P8 can be cut without touching a gate).
-
A failed gate recorded and filed against &133 rather than fixed here (P9).
-
The token routes' anonymous allowance per IP rises from 2/s to 500/s per replica (P2), leaving canopy-web’s edge limit to bound forwarded traffic; device authorization tightens from 120 to 30 a minute.
-
Sizing for one replica down at the peak (R − 1).
-
Issuance-log growth against the 3-year floor (P10) may make archival (#1303) an I3 prerequisite, a compliance call.
Verification
-
Per unit: fmt; clippy in both profiles; nextest for canopy-security, canopy-auth, canopy-api, canopy-test-lib and xtask;
rustdoc-private;quality-budgets;feature-builds;db-pools(U2, U4); the database tests withCANOPY_TEST_INFRA=requiredon a reloaded devstack;plan-lint. -
Harness: U4–U6 each end with
cargo xtask perf identity --quickpassing on a reloaded devstack (at U4, setup,READY, reports and teardown only). -
The record (U7):
cargo run --release -p xtask — perf identityon a host running nothing else; its gate table and outputs go into the as-built record and the guide; the JSON stays undertest-results/. -
Per MR:
cargo xtask dev reload, thengit push(the pre-push battery).
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 (2026-10-07) |
Anthropic |
claude-opus-5-5 |
no-ship. Two blockers, both fixed: the audit probe targeted dormant chain-v2 staging (P7, G4 and U6 now probe the v1 append); |