Profile before optimizing: break the 400 milliseconds into feature fetch, preprocessing, the model forward pass, and network, because the model is often not the largest slice. Then attack the biggest piece. Typical wins are concurrency on feature lookups, caching, quantization, a compiled runtime, a distilled model, and moving work off the request path. Target p99 specifically, not the mean.
Why interviewers ask this
This is a systems question wearing an ML costume, and interviewers want to see you measure before you optimize. Candidates who immediately propose a smaller model are guessing. Naming the non model components, especially feature fetching and serialization, and knowing that a tail far above the median usually means queueing or cold starts, are the markers of someone who has run a service.
How to structure your answer
- Refuse to optimize before you have a breakdown of the 400ms.
- Name the components you would time separately.
- Order the fixes by the size of the slice they attack.
- Note that p99 usually points at queueing, cold starts, or garbage collection.
Example answer
I would not touch the model until I have a breakdown. I trace one request end to end and time feature fetch, deserialization, preprocessing, the forward pass, postprocessing, and network. Every time I have done this on a service that felt slow, the model was a minority of the time. The last one was around 400 milliseconds total with about 90 in the model and over 200 waiting on three sequential feature lookups against a remote store. Fixing that was not an ML problem, it was issuing them concurrently and caching the two that only changed daily, and that alone got us most of the way. After that I look at the model: dynamic batching, int8 quantization, or exporting to a compiled runtime like ONNX Runtime or TensorRT, which on smaller models is frequently a two to three times win for no accuracy cost. The other thing about p99 specifically is that a tail that far above the median usually is not compute at all, it is queueing under load, a cold start on a fresh replica, or garbage collection. So I check whether p50 is already fine, because if it is, the fix is capacity and warm pools.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How does dynamic batching help throughput but hurt single request latency?
- What would you cache, and how would you invalidate it?
- How would you load test this to find the point where the tail blows up?
Related machine learning engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions