Lesson 11 of 17
5. Latency vs Throughput

5.10 When do latency and throughput fight each other?

3 min read+10 XP

On the highway: A bus carries 50 people in one vehicle, so many more people cross the city per hour. But you might wait 15 minutes at the stop for the bus to come and fill up. Great for the city's throughput, worse for your trip.

In the system: Several throughput tricks cost latency:

  • Batching: collecting writes into a batch before sending means each item waits for the batch to fill (or for a timer). Systems usually cap the wait: "send when 100 items are ready or 10 ms have passed".
  • Running servers very busy: high utilisation gets more work out of each machine, but queueing makes each request slower (5.8).
  • Small-packet merging: TCP's Nagle's algorithm waits briefly to combine tiny writes into fewer packets. It saves network overhead but adds delay, so latency-sensitive apps (games, trading, chatty protocols) often turn it off with TCP_NODELAY.
  • Compression: smaller responses (better for bandwidth) cost CPU time to compress and decompress.

And sometimes they help each other: caching makes requests faster and frees servers to handle more.

The design question: what does this feature need? A checkout button needs low latency. A nightly report or a log pipeline needs high throughput and doesn't mind waiting. Choose per path.

Memory code: "The bus moves more people, but you wait for the bus."