Video in progress

What is the difference between latency and throughput?

Latency is how long a single request takes (milliseconds), throughput is how many requests are completed per unit of time (RPS). They are related but not the same thing: you can have high throughput and bad latency too.

📖 Answer

The highway example: latency is how long one car takes to get from A to B; throughput is how many cars pass in an hour. If you add lanes, throughput goes up, but each car's speed doesn't change.

In a backend:

  • latency: GET /orders averages 40 ms, p99 is 350 ms;
  • throughput: the service handles 1200 requests per second.

How they relate: as load grows, queues appear (thread pool, connection pool) and latency starts to climb. Past a certain point throughput stops growing and latency shoots up: the system is saturated.

You need to watch both. If you look only at throughput, you think "1000 requests per second, all great", while in reality users are waiting 3 seconds for every page.

In Micrometer one Timer gives you both: throughput from _count, latency from _bucket or _max.