Part 2 · 1 chapters · ~8 min

Performance as a Discipline

Latency budgets derived from SLOs, benchmarks in CI with stable baselines, regression gates, query count and allocation budgets, load tests before launches, canary latency analysis, continuous profiling, and a recurring slowest-endpoints review.

6

Budgets with gates

code
// k6 thresholds: the test fails if the budget is broken
export const options = {
  scenarios: { steady: { executor: 'constant-arrival-rate', rate: 200, timeUnit: '1s', duration: '2m', preAllocatedVUs: 50 } },
  thresholds: { 'http_req_duration{route:create_transfer}': ['p(99)<300'], http_req_failed: ['rate<0.001'] },
};
// query budget test: a list endpoint must not issue N+1 queries
test('GET /v1/transfers uses at most 3 queries', async () => { const n = await countQueries(() => get('/v1/transfers?limit=50')); expect(n).toBeLessThanOrEqual(3); });

Use constant arrival rate, not a fixed number of virtual users, so a slow server cannot reduce the offered load and hide its slowness (coordinated omission).

PERFORMANCE AS A DISCIPLINE
from budget to gate to production check
definep99 budget per endpoint
swipe the figure sideways, or tap expand for full screen
1/4
budgets
Set latency budgets per endpoint from the SLO (SRE course): POST /transfers p99 under 300 ms, with a share for each dependency.
budgets from SLOsper endpoint