Chapter 1
Latency and Throughput
Measure how long work takes and how much work a system completes.
Latency is elapsed time for one operation, measured from a defined start to a defined finish. Throughput is the number of completed operations per unit of time. They answer different questions: a service can complete many requests each second while some individual requests remain slow. Clear boundaries matter because browser latency includes network and rendering work that server processing latency does not.
As incoming work increases, resources such as CPU, connections, or workers become busier. Near capacity, requests wait in queues before processing, so latency can rise sharply even if each operation's service time is unchanged. Throughput eventually reaches a ceiling. Measuring offered requests, completed requests, errors, queue time, and active work reveals whether the system is keeping up or merely accumulating a backlog.
For example, an image service completes 500 images per minute with two-second median latency. A burst of 700 per minute grows its queue and pushes completion latency higher while throughput remains near 500. In practice, define user-visible latency goals, measure throughput by meaningful operation, test behavior near expected peaks, and include failures rather than counting only successful work.
Latency describes one operation's wait; throughput describes the system's completion rate, and queues connect the two near capacity.
How to apply this
- Name the exact start and finish boundary for every latency metric.
- Track offered load, successful throughput, errors, and queue depth together.
- Set targets from user and business needs rather than from an isolated benchmark.
Situation
Jobs arrive faster than workers complete them, though the processing time reported inside each worker looks stable.
Decision
Measure end-to-end latency including queue wait and compare arrival rate with completion throughput before tuning worker code.