Home » API Load Testing: Throughput, Tail Latency, and Error Rates

API Load Testing: Throughput, Tail Latency, and Error Rates

Request tokens enter an API; separate throughput, latency-tail and error cards represent the observations a load test must preserve.

An API load test is useful when it connects a defined workload to observed throughput, latency distributions, and errors over a meaningful period. “It handled a thousand users” leaves the central questions unanswered: what those users did, how quickly requests arrived, what succeeded, and whether the load generator achieved its intended workload.

Start with a user journey and an operating question. For a ticketing API, that might be whether listing tickets and adding comments remain acceptable during the expected daytime mix, rather than whether one cached health endpoint returns quickly.

Specify the load before choosing a large number

Describe operation mix, data sizes, authentication behavior, request arrival pattern, test duration, and success criteria. Separate a routine-capacity question from a stress or recovery experiment. A breaking-point test is a different operation from validating an expected traffic level.

A proposed plan could distinguish three stages:

Stage Purpose Observation to preserve
Small baseline Check the script and expected response Request validity and workload composition
Sustained target workload Evaluate the operating question Completed work, latency distribution, errors, and saturation
Recovery observation Examine the system after load changes Backlog drainage, resource recovery, and persistent failures

This is a plan, not a report of executed traffic. Use an authorized test environment, synthetic data, and explicit stop conditions before pointing a generator at any service.

Know whether slow responses reduce your offered load

With a closed workload model, workers typically start another iteration after completing the previous one. If responses slow down, those workers can issue fewer new requests. The system may appear to stabilize partly because the test is offering less work.

Grafana k6's open-versus-closed model documentation explains that coupling and its relationship to coordinated omission. An arrival-rate model can decouple planned iteration starts from response time, subject to the generator's available capacity.

Choose the model that represents the question. A fixed set of users waiting between actions can justify a closed model; a service receiving independently arriving work may need an arrival-rate view. Neither label guarantees a correct script.

Record intended and achieved arrival rates, active workers, and iterations the generator could not start. A generator that runs out of resources has not established the API's capacity at the requested rate.

Read throughput, tail latency, and errors together

A high completion rate can coexist with an unacceptable slow tail. A low average can hide occasional requests that hold a connection for much longer. Report percentiles with their observation window, sample count, operation type, and outcome classification.

Do not combine a fast list endpoint and a slow comment endpoint into one reassuring percentile without also inspecting them separately. Distinguish network errors, HTTP failures, rejected business operations, and responses whose content violates the test's expectation.

The k6 API load-testing guide provides implementation-oriented guidance for designing API workloads. Your thresholds remain application requirements, not numbers a testing tool can choose universally.

Count the requests that did useful work

We scheduled 20 reads of synthetic tickets on loopback, one every 50 ms. The handler delayed successful responses for 24 ms. Every fourth request returned HTTP 503 after a 2 ms delay. Elapsed time ran from the start of the schedule through the last completed response. We measured each request at the client and used nearest-rank percentiles.

One local run over 0.9567 seconds
Population Count Observed p95
All completed requests 20 30.38 ms
HTTP 200 15 30.43 ms
HTTP 503 5 3.88 ms

Completed throughput was 20.91 requests/s. Successful throughput was 15.68 requests/s. The error ratio was 5/20, or 25%. If the acceptance condition requires every ticket read to succeed, the run fails even though every request received a response. With only five failed requests, their nearest-rank p95 is their slowest observation. Extending this sample into a capacity claim would require a workload and duration representative of the service.

Explain the bottleneck without confusing symptoms and cause

Correlate user-facing observations with database waits, pool contention, queue age, worker utilization, and resource limits when those measurements are available. A latency increase after adding workers is a hypothesis to investigate, not proof of a CPU shortage.

Our queue-capacity article explains why concurrency can move pressure into a downstream bottleneck. A load test should preserve that possibility instead of assuming that more virtual users or more workers always produce more useful throughput.

Keep environment differences visible: dataset size, cache state, external-service substitutes, connection limits, and deployment topology can change the result. A test against a simplified environment answers a narrower question.

Hand over an evidence package

Save the exact script, configuration, application revision, environment description, time window, achieved workload, and raw or appropriately aggregated results. Include failed thresholds and generator limitations. Rerunning only the successful interval produces a misleading history.

The local measurements above use a Python client and a loopback server. Record achieved arrivals and successful completions separately over the sustained workload before reporting a capacity result.

You may also like