Skip to main content
Fundamentalschapter 3 of 6 · 4 lessons

Latency vs Throughput

Why adding servers sometimes fixes a slow page and sometimes changes nothing.

You run a photo site. Somebody opens a profile, your server asks the database for that person's photos, and the page comes back. That round trip takes 200 milliseconds, and your four servers handle about 500 of those a second between them.

This quarter the profile page has been getting slower. It now takes 2 seconds. Traffic has not grown, no release went out, and support is filling up.

So the team doubles the servers, four to eight. The bill doubles. The page still takes 2 seconds.

Nothing was waiting for a free server, because there were always free servers. Every request was waiting on one database query that got slower as the photos table grew, and eight servers wait for that query exactly as long as four did. Buying the wrong one of these two things is the most expensive ordinary mistake in this field.

Lessons

4 in this chapter
  1. Two Different QuestionsFixing capacity does not make anything faster, and speed does not add capacity.3 min
  2. Percentiles, Not AveragesThe average hides the users you are losing. p99 is where the pain lives.3 min
  3. The Latency LadderMemory, disk, and network each cost orders of magnitude more than the last. Design around the jumps.2 min
  4. Trading One for the OtherBatching buys throughput with latency. Know when you are making that trade on purpose.3 min