Sizing the Fleet for Peak

Deep Learning in the Real WorldHard+30 XP+30

Sizing the Fleet for Peak

A writing app suggests the next few words while the user types, so its suggestion model is put behind an endpoint. Inference is stateless, so the team scales by running identical copies, each on its own GPU, with incoming requests spread evenly across them.

Each copy handles one batch at a time. Requests that arrive while it is busy queue up; the moment a pass finishes, the copy starts the next one with everything that has queued, up to a cap of bbb requests. A forward pass over a batch of nnn requests takes

12+0.75 n ms12 + 0.75\,n \text{ ms}12+0.75n ms

that is, 121212 ms of fixed overhead paid whatever the batch size, plus 0.750.750.75 ms per request in the batch.

The worst-placed request arrives just after a full batch has started without it: it waits out that entire pass, then rides in the next one, which is also full. So inside the model service the worst case is two back-to-back passes at the cap.

Every request also spends time outside the model, and batching changes none of it:

stagetime
network, there and back303030 ms
preprocessing666 ms
postprocessing444 ms

A suggestion is only useful if it feels instant, so the product rule is that the worst-case request must take no more than 100100100 ms end to end. At peak, 10,00010{,}00010,000 requests per second arrive. The team may choose any whole-number cap bbb, the same on every copy. The copies keep up if together they can finish requests at least as fast as requests arrive.

What is the smallest number of copies that keeps up with peak traffic while every request stays within the 100100100 ms budget?

Give the exact whole number.

latency
50 ms
throughput
100/s
wait 20 ms · batch 5

Hold requests briefly and run them together. Every user waits a little longer, and the system serves far more of them.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.