In brief
Performance tests in CI/CD produce false alarms when they measure noise instead of a change in the code: shared machines, a cold application start, too few measurements, and rigid absolute thresholds. You reduce them with a stable environment, a warm-up excluded from the assessment, several runs judged by the median, and a comparison with a baseline result from the same environment with a set tolerance. Tests are split into layers: short ones on every change, full ones nightly and before a release.
Where false alarms come from
A false alarm is a test that stops the pipeline even though the code did not slow the system down. After a few such cases the team starts to ignore the results or turns the test off, and then a real slowdown goes unnoticed. The most common causes:
- Shared machines. A CI agent on which other projects build at the same time gives a different result on every run.
- Cold start. The first minutes after deployment mean empty caches, JIT compilation in the JVM, and connection setup. A test that starts measuring from the first second measures the startup.
- Too few measurements. A five-minute test with a few hundred requests gives unstable p95 and p99, and a single slow request pushes the result over the threshold.
- Rigid absolute thresholds. A threshold of "p95 below 300 ms" set just above the current result raises an alarm at every fluctuation.
- Data and dependency drift. The test database grows with every run, and an external service answers fast one time and slowly the next.
A stable environment and warm-up
The first step is to remove variability that the code cannot explain. A performance test in CI runs on an environment with fixed parameters: the same machine types, the same configuration, and no other workloads during the test. In the cloud this means fixed instance types and an environment created each time from the same infrastructure code; more in the article Environment for performance testing.
The second step is warm-up. The test begins with a few minutes of traffic that do not count toward the assessment, and only then starts measuring. Data is restored to its initial state before every run, and external services are replaced with stubs with a fixed delay, so that the test measures your own system and not the provider's network.
Several runs and comparison with a baseline
A single run is one sample from a distribution of results. A more stable assessment comes from several shorter runs and the median of their p95 than from one longer run. The result is compared not only with a threshold but with a baseline result: the median of the last runs on the main branch, in the same environment and with the same scenario.
An assessment rule might look like this (example values):
| Result relative to baseline | Decision |
|---|---|
| p95 worse by less than 10% | test passed |
| p95 worse by 10–20% | warning in the pipeline, the change goes through, the team reviews the result |
| p95 worse by more than 20% or error rate above the threshold | pipeline stopped |
You set the tolerance based on the variability of results: if consecutive runs of the same code differ by 8%, a 5% tolerance will raise an alarm every few runs. A good practice is to record the code version, configuration, and environment with every result, so that when an alarm fires it is immediately clear what changed. The error rate is judged by an absolute threshold, because an error is an error regardless of the baseline.
Test layers in the pipeline
A full load test takes too long to run on every change, and a short test will not detect a memory leak. That is why tests are split into layers:
- On every change: micro-performance tests of critical functions (e.g. fee calculation, application validation) and a short test of a few key API operations at low load. A few minutes, compared with the baseline.
- Nightly: a load test at the level of typical traffic on an environment with fixed parameters, with several runs. The result goes to a trend dashboard.
- Before a release: a full load test at the forecast peak level, a stress test, and, for larger changes, an endurance test. They are described in the article Load, stress, and endurance tests.
This split catches large regressions quickly and at the same time does not block the team for an hour on every change. In a SaaS product with many customers, as in the case study Test automation for a B2B SaaS product in a multi-customer pipeline, the nightly layer also covers the configurations of the largest customers.
Thresholds in the script and trend instead of a single result
Performance testing tools let you write the pass criteria in the script itself. In Grafana k6 this is done with thresholds; a test that does not meet them ends with an error code and the pipeline stops it:
export const options = {
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<500', 'p(99)<1500'],
},
};Absolute thresholds in the script are a good safety net for large regressions. The comparison with the baseline is usually a separate step that reads results from several runs. In JMeter the test is run in non-GUI mode, and the results from the .jtl file are assessed by a script or a plugin in the pipeline; a comparison of the tools from this angle is in the article JMeter, Gatling, or k6.
The trend says the most. A dashboard with the p95 of key operations from consecutive nights shows the system slowly getting worse, which no single threshold will stop: five changes of 3% each add up to a clear slowdown, even though each one on its own is within tolerance. So once every few weeks it is worth comparing the current result with the result from several releases ago. The choice of a tool for pipeline testing is covered in the article JMeter, Gatling, or k6.
Questions and answers
Do performance tests in CI make sense on shared agents?
Only for very large regressions, e.g. a twofold slowdown. For comparisons with a tolerance of a dozen or so percent, you need an environment with fixed parameters where nothing else runs during the test. Without that, the variability of results is greater than the changes the test is meant to detect.
What should I do when a performance test fails and nobody changed anything significant?
First, run it again on the same version and compare it with the baseline result. If the second run is within tolerance, check the environment: other load on the machines, data size, external dependencies. If this keeps happening, you need to fix the test or the tolerance, not get the team used to rerunning.
How long should the test be on every change?
A few minutes, including warm-up. A longer test slows the team down and still will not replace the nightly tests and the tests before a release. On every change, what counts is quickly detecting a large regression in a few key operations, while the full performance assessment belongs to the longer layers.
Should the threshold be absolute or relative?
Ideally both. An absolute threshold, derived from requirements or an SLO, protects against crossing a line the business considers impassable. A relative threshold, meaning a comparison with the baseline result, catches slowdowns long before that line is reached. The error rate is always judged by an absolute threshold.
Sources