Lesson 10 of 17
5. Latency vs Throughput

5.9 How do you increase throughput?

3 min read+10 XP

On the highway: To get more cars through per hour: add lanes, add toll booths (the narrowest point decides everything), and put people on buses so each vehicle carries more.

In the system:

  1. Find the bottleneck. Throughput is capped by the slowest part. Adding app servers does nothing if the database is the limit. Measure which resource runs out first: CPU, database connections, disk, network, a lock.
  2. Add capacity there: more app servers (scale out, Chapter 6), read replicas (Chapter 14), more partitions (Chapter 15), more consumers on a queue (Chapter 22).
  3. Do more at once: more worker threads or async I/O, so a server isn't idle while waiting for the database. Little's law (5.6) tells you how much concurrency you need.
  4. Batch: write 100 rows in one database call instead of 100 calls; send messages in groups. Each trip carries more.
  5. Do less per request: caching, smaller responses, cheaper queries.

Remember the bottleneck moves. Fix the database and the next limit might be the network or a single lock in your code. Measure again after every change.

Memory code: "Widen the narrowest point." More lanes anywhere else don't help.