QA Interview Hub · Knowledge base · Quizzes · Українська

Performance Testing › Test design

How to plan a performance test

A performance test is planned before the first run: define measurable goals and realistic scenarios and request rates from production data. Ramp-up, think time, a production-like environment with realistic data and a warm-up excluded from the result are also needed. For public traffic use an open model: a closed model with fixed virtual users throttles the load itself and hides saturation.

Performance · Planning

The test showed an average of 333 ms, yet production would have collapsed at that traffic. Why did the test lie?

The real peak of checkout is 150 requests per second, and the system, by measurement, can handle about 120. The team runs a test: 100 virtual users, a half-second pause between actions. The report: throughput 120 RPS, average response time 333 ms, no errors, the goal "p95 < 500 ms" is met. The test passed, although in production such a system would quickly collapse. A test that looks serious but does not resemble reality gives false comfort. Below is what to define before the first run, and a breakdown of exactly this case.

How it works and why. What to define before the first run:

  • Goals and pass criteria: measurable and set in advance, for example "p95 < 500 ms and errors < 1 % at 150 RPS". They come from the SLA/SLO, not invented after the test;
  • Workload model: which scenarios users run, in what proportion and at what intensity. The basis is production data (logs, analytics): the mix of operations and the peaks;
  • Load model: open or closed (below);
  • Ramp-up: a gradual increase of load, to see from which level degradation starts;
  • Think time: pauses between user actions. Without them the same number of VU creates far more requests than real users;
  • Environment and data: as close to production as possible (configuration, database data volume, caches, integrations or their stubs with a realistic delay);
  • Warm-up and baseline: the first requests are slower (caches, JIT, connection pools), so warm-up is not counted in the result, and reference measurements on a known version give something to compare with.

Open or closed. In a closed model there is a fixed number of VUs: each sends a request, waits for the response, pauses and repeats. New load appears only after the previous request completes, so when the server slows down the generator itself sends fewer requests. In an open model requests arrive at a set rate (say 150 per second) regardless of responses, as real users do, who know nothing about the server state. That is why the closed model is prone to coordinated omission: while VUs wait for a slow response, no new requests are sent, and the delays a real user would have felt do not reach the statistics. The tail looks better than it is. The model follows the system: closed fits when the number of concurrent clients is truly limited (an internal service with a worker pool, a fixed number of terminals), open fits public internet traffic.

What happens while the server stalls

Open: requests follow a scheduleClosed: VUs wait for responsesred: a stall; the closed model sends nothing
Figure 1. In the open model requests keep arriving and pile up. In the closed model VUs wait, so the delays during that time are not measured.

Example: from false comfort to an honest test. First the initial version with the closed model:

import http from 'k6/http';
import { sleep } from 'k6';

// 100 VU, 0.5 s pause, no target for the request rate
export const options = { vus: 100, duration: '10m' };

export default function () {
  http.post(__ENV.BASE_URL + '/api/checkout', JSON.stringify({}));
  sleep(0.5);
}
ModelOffered loadThroughputResponse timeConclusion
Closed, 100 VU, 0.5 s pause100 / (R + 0.5)120 RPS (the system ceiling)≈ 0.33 sA green report
Open, 150 requests/sExactly 150 RPSNo more than 120 RPSGrows every minuteThe system cannot hold the peak

Why this happened. The system handles 120 RPS. 100 VU with a 0.5 s pause "would like" to create 200 RPS, but the system answers slower, and Little's law gives a steady state: 100 / 120 ≈ 0.83 s per cycle, that is a response time of 0.33 s. The closed generator itself held the load down to 120 RPS, and the report looks acceptable. The real 150 requests per second arrive regardless: every second the queue grows by 30 requests, responses get longer, and eventually come timeouts and errors. That is exactly the saturation the closed test hid.

The fix: an open model with the real rate, warm-up as a separate scenario (the threshold and the summary only for the main scenario), and a threshold on dropped_iterations. In k6 an iteration is dropped when no VU is free for it, so a counter above zero says directly that the system cannot keep up:

export const options = {
  scenarios: {
    warmup: {
      executor: 'constant-arrival-rate',
      rate: 20, timeUnit: '1s', duration: '2m',
      preAllocatedVUs: 50, maxVUs: 200,
    },
    checkout: {
      executor: 'constant-arrival-rate',
      rate: 150, timeUnit: '1s', duration: '10m',
      startTime: '2m', // after the warm-up
      preAllocatedVUs: 200, maxVUs: 2000,
    },
  },
  thresholds: {
    'http_req_duration{scenario:checkout}': ['p(95)<500'],
    'http_req_failed{scenario:checkout}': ['rate<0.01'],
    dropped_iterations: ['count==0'],
  },
};

The same 150 requests per second in two tests

Typical

Closed: 100 VU and a pause

Throughput is stuck at 120 RPS, average 333 ms, no errors. The generator slowed itself down, so the overload is not visible.

Better

Open: 150 requests per second

Response time grows, timeouts and dropped_iterations appear. The test showed that the peak exceeds the capacity of the system.

Figure 2. The closed model adapts to a slow server and hides saturation. The open model keeps the pace of real users.

Limits and alternatives. The open model requires knowing the real rate: take it from production logs or analytics (requests per second at the peak, the split by scenario), not from the number of "users online". For a new system with no traffic, use a business estimate with a margin and refine it later. Little's law lets you convert: if at the peak 3000 users act every 20 s (think time 20 s, response 0.5 s), the rate is ≈ 3000 / 20.5 ≈ 146 RPS. Separately, the generator: its CPU and network easily become a ceiling, and then the test machine is the bottleneck. If the test is spread over several generators, their clocks and samples are synchronised and merged on raw data.

Typical mistakes.

  • A closed test for public traffic: overload stays hidden, the tail is understated.
  • Zero think time "to be tougher": the rate is unrealistic and the conclusion about the limit is meaningless.
  • A goal invented after the test: "it fits because it came out that way".
  • Warm-up counted in the result: the first slow requests spoil p95 or, the other way round, cold caches stay hidden.
  • One scenario instead of the real mix of operations from production.
  • A generator on the same machine as the application, or on an overloaded one.
  • A test on an empty database: indexes and caches behave differently than on a real volume.

Check yourself

Why did a closed test with 100 VU show an average of 333 ms for a system that holds 120 RPS when the real peak is 150 RPS?

Answer

The closed generator sends the next request only after a response, so it held the pace down to what the system can do (≈ 120 RPS). Real users do not wait: their 150 RPS arrive independently and the queue grows. This is coordinated omission: the slow delays never reached the statistics.

What does a non-zero dropped_iterations mean in k6 for an open scenario?

Answer

No free VU was found for a planned iteration: the system cannot keep up with the set rate, or maxVUs is too low. First check that the generator is not the limit, then the system.

Why is warm-up a separate scenario, and why is the threshold set only on the main one?

Answer

The first requests are slower because of cold caches, JIT and connection pools. Counting them makes p95 falsely worse or muddles comparisons. A threshold on the scenario tag separates warm-up from the measurement.

In an interview. Junior: Before a test I define the goals (p95, errors), the scenarios and their proportions, ramp-up, think time and an environment close to production, and I do not count warm-up in the result. Middle/Senior: For public traffic I use an open model with the real rate from logs, because the closed model hides saturation and understates the tail through coordinated omission. I recompute the rate with Little's law, take goals from the SLO, add a dropped_iterations threshold in k6 and make sure the generator itself is not the limit.

More articles in this chapter