Core Concepts

Latency vs Throughput

Measure how long one request takes, how many finish per second, and why waiting rises when work arrives faster than it can finish.

Free~14 min

Latency measures how long one operation takes. Throughput measures how much work finishes in a given interval. Measure both at the load the design must handle. A fast operation on a quiet system can spend much longer waiting as demand rises.

Two measurements

TermWhat you measureOnline Chess example
LatencyElapsed time from start to finish for one operationTime from a move submission to the opponent seeing it
ThroughputOperations or bytes completed per unit timeMoves delivered to opponents per second

Name the start and finish of your latency measurement. An acknowledgement from an API and a message becoming visible to its recipient can happen at different times. For throughput, say what counts as finished and over which interval.

Percentiles and averages

Order the measured latencies from fastest to slowest. p50 is the median. p99 is the time by which roughly 99% of the operations finished.

Suppose 98 requests finish in 40 ms and two take two seconds. The average is about 79 ms. The 99th request in the sorted sample took two seconds. The percentile makes that slow part of the experience visible.

Tie the measurement to load and a time window. A p99 target at 10,000 requests/s says more about the service under load than a number measured when it is idle. Google SRE on service-level objectives

How they trade under load

A worker can finish 100 requests each second. At a steady 60 requests/s it can usually clear work as it arrives. If clients send 150 requests/s and the service accepts them all, the worker can still finish only 100/s. The backlog grows by about 50 requests each second. A request near the back spends more time waiting even if the worker takes just as long to process it as before.

When the flow is stable, Little's Law connects the averages. Average work in the system equals average arrival rate multiplied by average time in the system. At 80 accepted requests/s and an average time of 50 ms from admission to completion, about four accepted requests are in the system on average. That includes requests waiting and those being processed. A backlog that keeps growing needs its own arrival-versus-completion calculation. Little's Law proof

What changes the measurements

MechanismEffect to check
BatchingOne database flush or model step can handle several operations. Check how long a request waits for the batch and whether the shared work raises throughput.
More workersExtra workers can finish more requests if the constrained work can be shared. Check whether they hit the same database or network limit.
Synchronous replicationA write can wait for a copy elsewhere. Check which acknowledgement the system requires and how much time it adds.
Rejecting excess workA smaller accepted load can keep the queue from growing. Track the rejected requests as well as completed throughput.

Write-Ahead Log shows how concurrent commits share a flush. Data Replication explains what the writer can wait for before reporting success.

Interview habit

  1. Name the operation, the measurement boundaries, and the load.
  2. Say which target binds the design, such as p99 move latency or completed inferences per second.
  3. Explain where a request can wait and which resource limits completions.
  4. State what you would measure before adding workers, batching, or limiting admission.

Common mix-ups

  • Counting arrivals as completions when the queue keeps growing.
  • Reporting only average latency when the target is p99.
  • Using a latency percentile in a calculation that needs an average.
  • Adding read replicas to a write bottleneck without explaining which resource they relieve.

See also

Used in

  • Online Chess - measure move submission to opponent visibility and keep that path short under concurrent play.
  • Batched Inference Service - trade time waiting in a batch for more requests processed per model step.
  • ChatGPT - time to the first visible reply event and total time to finish a turn describe different parts of the user experience.

Done reading? Mark it so it sticks in your dashboard.

Discussion