Throughput 00:00:01 Four hundred requests arrive every second Four hundred people per second can arrive at a counter that completes only a hundred requests per second. A busy worker is not proof that the system is keeping up. Follow completed requests as well as arrivals. It finishes 100. The queue grows by 300 every second. With two identical workers, two hundred requests complete each second and another two hundred still accumulate. Four workers can just match four hundred arrivals per second in this simplified model. They have no spare capacity to clear a burst. Six identical workers serve the same four hundred requests at about two-thirds average utilization. Still 400 finished. More than arrives cannot be finished. Adding idle workers after all arriving work is already served cannot create additional completions. A load test must distinguish offered demand from the capacity it set out to discover. 00:00:55 The narrowest stage sets the pace Change the workload to two thousand requests a second and send each one through an API and a database. High capacity at the entrance helps only while downstream stages can sustain the same flow. 2,000 requests a second arrive. The API can do 10,000. The database completes only one hundred of those requests each second. End-to-end throughput is limited to that rate. Doubling API capacity to twenty thousand per second changes nothing at the database. The query no longer scans a table. Say the database now does 4,000. All 2,000 finish. The database is still the narrowest stage, at 4,000. The slowest stage can move when you change the design. Recheck completed traffic at the user boundary after each change, rather than adding up the individual services' headline rates. 00:01:45 How much work is inside? In a stable system, together the completion rate and average time spent inside the boundary determine the average number of requests in flight. Keep seconds and milliseconds straight while following the next three estimates. At a thousand completions per second and an average response time of two tenths of a second, about two hundred requests are in flight on average. At the same rate, reducing the mean response time to fifty milliseconds brings the average number in flight down to fifty. 200 workers at 0.4 s finish 500 a second, not 1,000. If a pool serves three thousand database operations per second and each occupies a connection for five milliseconds, fifteen connections are busy on average. At fifty milliseconds each, that becomes a hundred fifty busy connections. A pool capped at a hundred cannot sustain those assumptions. The calculation is an average. It cannot predict an individual slow request, and an ever-growing queue violates the steady-state assumption behind this useful calculation. 00:02:47 Share the fixed cost of a write A database round trip has a fixed cost before it processes any rows. Grouping rows amortizes that cost. Predict what happens to the first item in a batch as the batch size keeps growing. With one row per batch, this illustrative test finishes about a hundred ninety-eight rows per second. Most of the batch time is fixed overhead. Ten rows per batch raise throughput about ninefold because the ten rows share the same round-trip overhead. At a hundred rows per batch, this workload reaches about ten thousand five hundred rows a second. At a thousand rows per batch, twenty thousand rows a second complete, and one batch takes fifty milliseconds. Ten thousand rows per batch buys only about ten percent more throughput, while one batch now takes nearly half a second. The busiest benchmark configuration may make an individual item wait too long. Pick a bound on batch size and waiting time that still satisfies the callers. 00:03:44 A counter needs two readings A dashboard says a service completed forty-five thousand requests. Without the time interval, that number cannot tell an engineer whether the service was crawling or keeping pace with a busy sale. One number says nothing about the rate. 60,000 more in 60 seconds: 1,000 a second. The process restarts and the counter is 0. Not minus a million. 45,000 in 50 seconds: 900 a second. Use the difference in completed counts divided by elapsed time, handling restarts appropriately. Then compare the result with arrivals and latency. Those three observations distinguish healthy growth from a growing queue.