Bookmarks

Latency

The time between sending a request and receiving the response: for example, how many milliseconds a packet takes to travel from client to server and back.

Also: network latency, network delay, delay

checked 9 Nov

All terms

Every user of a distributed system feels latency: a page does not open, a transaction is not confirmed, and a model cannot answer faster than data can cross the network and be processed. Latency cannot be reduced to zero, because it has a physical limit, so it is measured, described with percentiles and built into the architecture.

What latency is made of

Everything along the way affects a request’s journey from client to server and back:

FactorWhat happensOrder of magnitude
Medium and distancethe signal travels through fibre or radio; fibre is faster than wirelessabout 5 ms per 1,000 km of fibre
Transmission onto the linkthe packet is serialised byte by byte on each outgoing port1,500 bytes at 1 Gbit/s: about 12 µs
Routing hopseach router on the path consults its routing table and forwards the packetmicroseconds per node, with dozens of nodes
Server processingthe application and database compute the responsemilliseconds
Queuingunder load, requests wait for a free processor or linkfrom zero to hundreds of milliseconds when overloaded

The practical conclusion is that even a perfectly tuned system cannot respond faster than geography allows. Tashkent and Frankfurt are about 4,700 km apart in a straight line. A signal in fibre needs at least 23 ms one way, so the full round trip takes twice as long, before any processing at intermediate nodes.

RTT: why we measure the full round trip

The simplest thing to measure is the time for a full round trip, the RTT (round-trip time), as the ping utility does. RFC 2681 defines the round-trip delay metric as the time from the source sending a packet to the response arriving back at the source. Such a measurement needs no special software on the other end and no synchronised clocks at both ends, which one-way delay measurement requires. The price of simplicity is inaccuracy: the outbound and return paths may differ, so RTT actually measures two different routes at once, and one-way delay is estimated as half the round trip.

Percentiles: p95 and p99

The average latency hides the worst cases. In an example from the Google SRE book, a typical request is served in about 50 ms, but 5% of requests take twenty times longer, and the average does not show it. So latency is described with percentiles, the values below which a given share of requests fall:

PercentileMeaningExample for 1,000 requests
p50 (median)half of requests are faster than this value20 ms
p95slower: 50 requests out of 1,00080 ms
p99slower: 10 requests out of 1,000250 ms
p99.9slower: 1 request out of 1,000800 ms

That is why quality is not promised “on average”: an SLO target is phrased as “99% of requests faster than 300 ms”, which is a percentile target. The tail also compounds: a page with ten parallel sub-requests hits the slow 1% with a probability of almost 10%, so the p99 of the whole page ends up noticeably higher than that of each service on its own.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • throughput

    Throughput is how much data a link carries per second, while latency is how long a single packet takes to reach its destination. A link can be wide and slow at the same time.

In depth in the references

where the topic is covered in detail