One response takes 800 ms, yet the load test reports a p99 of 5 ms. A client that waits for each response before sending its next request skips requests that would otherwise arrive during the pause. When the intended workload has independent arrivals, this gap in measurement is called coordinated omission.
The guide to latency percentiles explains how to read p95 and p99. Here we measure the same service pause under two workload models.
Separate arrival timing from service time
In a closed-loop test, a virtual user waits for the previous request to finish before starting another. That makes sense when users wait for the previous screen to load. If many independent clients are expected to send requests at a fixed overall rate, slow responses throttle a closed-loop test and hide the queue that would form at that rate.
An open-loop test schedules arrivals independently. A request can arrive every 20 ms while the previous request is still processing. In this example, latency runs from arrival to completion. Timing only the service interval leaves queueing delay out of the measurement.
Simulate ten seconds of arrivals
The server handles one request at a time. A request normally takes 5 ms, but one starting from 2,000 through 2,019 ms takes 800 ms. The closed-loop client schedules a request no sooner than 20 ms after the previous one and waits for its response. The fixed-arrival model offers one request every 20 ms. Count requests arriving before the ten-second mark and follow them through completion. Compute percentiles using nearest rank.
from math import ceil
DURATION_MS = 10_000
INTERVAL_MS = 20
def serve(arrival, available):
start = max(arrival, available)
service = 800 if 2_000 <= start < 2_020 else 5
finish = start + service
return finish, finish - arrival
def closed_loop():
arrival = 0
latencies = []
while arrival < DURATION_MS:
finish, latency = serve(arrival, arrival)
latencies.append(latency)
arrival = max(arrival + INTERVAL_MS, finish)
return latencies
def fixed_arrivals():
available = 0
latencies = []
for arrival in range(0, DURATION_MS, INTERVAL_MS):
available, latency = serve(arrival, available)
latencies.append(latency)
return latencies
def percentile(values, p):
return sorted(values)[ceil(p / 100 * len(values)) - 1]
for name, values in (
("closed", closed_loop()),
("fixed", fixed_arrivals()),
):
print(name, len(values), *(percentile(values, p) for p in (50, 95, 99)))
| Workload | Arrivals | p50 | p95 | p99 |
|---|---|---|---|---|
| Closed loop | 461 | 5 ms | 5 ms | 5 ms |
| Fixed arrivals | 500 | 5 ms | 425 ms | 725 ms |
The closed-loop request sent at 2,000 ms finishes at 2,800 ms. The client misses 39 scheduled arrival slots while waiting. Under fixed arrivals, the request at 2,020 ms waits until 2,800 ms, then finishes at 2,805 ms for a latency of 785 ms. The tail grows because the stall affects later requests in the queue. These values describe a single-server simulation, with real systems depending on concurrency, queue limits, and overload behavior.
Measure the workload you intend to simulate
- Choose the workload model. Use arrival-rate scheduling when modeling independent arrivals. Use a closed loop when modeling users who wait for a response. k6 workload models
- Record scheduled start, actual start, and finish. Separate delays at the load generator from the latency after sending the request.
- Count arrivals, failures, timeouts, and missed starts. If the load generator runs out of capacity, count the missed work separately. A percentile over successful requests cannot show a drop in the success rate.
- Compare with the service’s own histogram. Keep the client-side measurements for waiting time that the server cannot observe. Prometheus p95 and SLO calculations
FAQ
Why can a closed-loop test report a low p99?
While the client waits for a slow response it sends no new requests, leaving their potential queueing delay out of the measurement.
When is a closed-loop load test appropriate?
It suits workloads in which a fixed population of users waits for a response before taking its next action.
Does an open-loop test measure all latency automatically?
Track scheduled arrival through completion, and count work the load generator could not start as well as timeouts.