AlgoViz

Latency

easy 30 min

Latency is how long one request takes.

Remember it

The few things worth knowing cold, and how to make them stick.

Memory hook

One request, how long? Travel, wait, work, store.

A pizza: waiting in line, baking, and the road. A nearer shop, ready bases and two ovens bring it sooner.

Cheat sheet

Units
1 ms = 1,000 µs = 1,000,000 ns
Memory / SSD / zone
100 ns / 100 µs / 0.5 ms
Fibre
200 km per ms
Sequence / parallel
add / take the slowest
Fan-out
1 - 0.99^n
Busy server
S / (1 - load)
Feels instant
about 100 ms

Spot it when you see

  • "It must feel instant."
  • Users on other continents.
  • A page that calls many services.
  • Someone quotes an average.

Tricks that stick

  • LATENCY. L: lower is better.
  • A: always measure.
  • T: the tail matters (P99).
  • E: edge caching.
  • N: the network is slow when it is long.
  • C: cache what is read often.
  • Y: your users feel it.

Do not forget

  • Doubling the server time for a round trip.
  • Averaging percentiles.
  • Measuring only at the server.
  • Timing with the wall clock.
  • Hedging requests that are not safe to repeat.