Scrivio Interview library
ConceptIntermediate7 min read · updated 12 November 2026

Explain latency versus throughput, why average latency is misleading, and how you should measure and report latency for a service.

Throughput is how much work a system completes per unit of time, and latency is how long one operation takes; they are linked, because as utilisation rises, queueing makes latency climb sharply. Averages hide the slow tail that users actually feel, so we report percentiles such as p50, p99 and p99.9 plus the maximum, record them with an open-model load generator and HdrHistogram to avoid coordinated omission, and state throughput at a latency target. Little's law, concurrency equals throughput times latency, ties the two together for capacity planning.

Why this question is asked

Almost every performance discussion eventually becomes an argument about numbers, and most of those arguments come from measuring the wrong thing. A dashboard showing an average response time of 40 ms can sit next to a stream of customer complaints about timeouts. Interviewers ask this question to see whether we know which numbers describe user experience, how load tests can lie, and how latency and throughput affect each other. In this answer, we will define the two terms, see why latency rises with load, show why averages mislead, explain coordinated omission, and finish with how to report results and use Little's law.

1Two Different Questions

Throughput answers the question how much: requests per second, messages per second, rows imported per minute. Latency answers the question how long: the time from sending a request to receiving the full response, as seen by the caller.

They are easy to confuse because improving one often helps the other, but they can also move in opposite directions. Batching, for example, raises throughput because fixed costs are shared across many items, but each item now waits for its batch, so latency goes up. A system tuned only for throughput can be very bad for interactive users, and the other way round.

2Why Latency Rises Sharply With Load

Every server has some capacity, the rate at which it can complete work. Utilisation is the fraction of that capacity in use. When utilisation is low, a request usually finds a free thread and is served at once. As utilisation rises, requests increasingly arrive while others are being served, and they wait in a queue. That waiting is added to the service time.

A simple queueing model shows the shape. For a single server with random arrivals, the average time in the system is the service time divided by one minus the utilisation. The exact formula varies for real systems, but the curve is always the same: almost flat, then a steep wall.

Java
// Service time 10 ms, simple single-queue model: time = service / (1 - utilisation)
// utilisation 50% -> 10 / 0.5 = 20 ms
// utilisation 80% -> 10 / 0.2 = 50 ms
// utilisation 90% -> 10 / 0.1 = 100 ms
// utilisation 95% -> 10 / 0.05 = 200 ms

So pushing a service from 80 to 95 percent utilisation adds only 19 percent more throughput but quadruples latency. This is why capacity plans keep headroom, and why raw maximum throughput is a misleading number on its own.

3Why Averages Mislead

Latency distributions are not symmetric. Most requests are fast, and a few are very slow because of a GC pause, a cold cache, a lock, a retry or a slow dependency. The average mixes these together into a number that may describe nobody.

Java
// 1,000 requests: 980 take 10 ms, 20 take 2,000 ms
// average = (980 x 10 + 20 x 2000) / 1000 = 49.8 ms
// p50 = 10 ms (half the requests were faster than this)
// p99 = 2,000 ms (1 in 100 requests was at least this slow)
// max = 2,000 ms
What each number tells us
MetricAnswersWatch out for
Averagetotal time divided by counthides the tail; describes no real request
p50 (median)the typical requestsays nothing about slow requests
p99, p99.9how bad the tail isneeds many samples to be stable
Maximumthe worst stall seenone outlier; check if it repeats

The average says 50 ms, but no request took 50 ms. Two percent of users waited two seconds, and the average hides that completely. Percentiles describe the distribution directly: p99 is the value that 99 percent of requests were faster than. Tails also matter more than they look. A page that makes 20 backend calls hits the p99 of at least one of them on about 18 percent of page loads, so the backend's tail becomes the user's typical experience. So we report p50 for the typical case, p99 and p99.9 for the tail, and the maximum, because the maximum often reveals pauses that percentiles round away.

4Coordinated Omission: When the Load Test Lies

Many load generators work in a closed loop: each virtual user sends a request, waits for the response, then sends the next one. That seems natural, but it has a flaw. When the server stalls, the load generator stops sending, so it records only one slow request for the whole stall, while real users, who keep arriving on their own schedule, would all have been stuck.

Suppose a test should send 100 requests per second, and the server freezes for one second. A closed-loop client records one request at about 1,000 ms and then carries on. In reality, the 100 requests due during that second would have waited between 0 and 1,000 ms each. The test reports a near-perfect p99 for a system that was frozen. This is called coordinated omission, because the measuring tool coordinates with the system under test and omits exactly the bad samples.

Step throughA one-second stall seen by a closed-loop client
Load generatorServer
request 1 at 0 ms
reply at 1,000 ms (server stalled)
records one slow sample
request 2 sent only now
reply at 1,010 ms
99 requests that were due never happened

6 messages in order. Play them, or step through them one at a time.

An open-model generator would have sent those 99 requests and recorded their waits.

The fix has two parts. We use an open-model load generator, one that sends requests at a fixed arrival rate regardless of whether earlier responses have come back, such as wrk2, Gatling's open injection profiles or k6's constant-arrival-rate executor. And we record latency from the intended send time, typically into HdrHistogram, a histogram designed for latency that keeps percentiles accurate across a wide range and can correct for expected intervals.

5Reporting Throughput and Latency Together

Because latency explodes near saturation, the maximum throughput a server can reach is not useful by itself: at that point every request is slow. The meaningful number is the highest throughput the service sustains while meeting its latency target, for example 2,400 requests per second with p99 under 100 ms. We find it by running the test at increasing fixed rates and noting where the percentile curve crosses the target.

6Little's Law for Capacity Planning

Little's law states that the average number of requests in a system equals the arrival rate times the average time each request spends there. It holds for any stable system, whatever the distribution, which makes it a reliable planning tool.

Java
// L = lambda x W
// 2,000 requests/s x 0.050 s average latency = 100 requests in flight on average
// If each in-flight request holds a database connection for 20 ms of its 50 ms:
// 2,000 x 0.020 = 40 connections busy on average -> size the pool with headroom above 40

So when someone proposes a thread pool of 10 for a service that must handle 2,000 requests per second at 50 ms, Little's law tells us immediately that it cannot work: we need about 100 requests in progress at once. It also tells us that if latency doubles under a slow dependency, the number of concurrent requests doubles too, which is how slow dependencies exhaust thread and connection pools.

7Follow-up questions

Why is p99.9 harder to measure than p50?

Because it describes rare events. To estimate p99.9 reliably, we need many thousands of samples in each reporting window, so for low-traffic services we report it over longer windows or accept that it is noisy. Averaging percentiles across servers or time windows is also wrong; we merge the histograms and compute the percentile from the merged data.

Should latency be measured at the server or the client?

Both, because they answer different questions. Server-side timing shows how long our code took. Client-side or edge timing includes queueing before the request reached our code, network time and load balancer delays, which is closer to what users feel. A large gap between them points to queueing or the network.

What is the difference between response time and service time?

Service time is the time spent actually working on the request. Response time is service time plus all waiting, mainly in queues. Under load, service time stays about the same while response time grows, which is exactly the queueing effect.

8Conclusion

In this answer, we separated throughput, work per unit of time, from latency, time per operation, and saw that queueing makes latency rise steeply as utilisation approaches capacity. Averages hide the slow tail, so we report p50, p99, p99.9 and the maximum. Closed-loop load tests suffer from coordinated omission, which we avoid with open-model tools and HdrHistogram-based recording from intended send times. We state throughput at a latency target, and we use Little's law, concurrency equals throughput times latency, to size pools and plan capacity.

What to say in the interviewAbout 90 seconds aloud

Open with

Throughput is the amount of work done per unit of time, like requests per second, and latency is the time a single operation takes. They are linked through queueing: as utilisation rises, requests start waiting for each other, and latency goes up slowly at first and then very sharply near capacity, so the last 15 percent of throughput can multiply latency several times.

Then, if they want more

Average latency is misleading because latency distributions have long tails. If 98 percent of requests take 10 ms and 2 percent take two seconds, the average is about 50 ms, which describes nobody. So I report percentiles, p50 for the typical case, p99 and p99.9 for the tail, plus the maximum, and I merge histograms rather than averaging percentiles.

For measurement, I watch out for coordinated omission: a closed-loop load generator stops sending while the server is stalled, so it records one slow request instead of all the ones that should have queued up.

I use an open-model tool with a fixed arrival rate, like wrk2, Gatling open injection or k6 constant arrival rate, and record into HdrHistogram from the intended send time. I report throughput at a latency target, such as requests per second with p99 under 100 ms.

And for capacity I use Little's law: concurrency equals throughput times latency, which tells me how many threads and connections I need.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain latency versus throughput, why average latency is misleading, and how you should...": https://scrivio-interview-library.netlify.app/java/java-performance/64acd4c997/