Minimum Model Replicas to Meet a Queueing Wait SLA
Last updated: November 29, 2026
Quick Overview
Requests arrive at known times with known service durations and are served first come, first served by the replica that frees up earliest. Find the minimum number of replicas so that no request waits longer than W milliseconds.
Sierra
November 29, 20260
0
0 solved
Requests arrive at known times with known service durations and are served first come, first served by the replica that frees up earliest. Find the minimum number of replicas so that no request waits longer than W milliseconds.
Sierra's voice agents are latency sensitive, so capacity planning for model serving must bound queueing delay, not just average throughput. The interviewer wants you to spot binary search on the answer, justify monotonicity, and write the heap simulation correctly.
What the Interviewer Expects
- Write a min-heap simulation of k servers under FIFO
- Argue that more replicas never increase any request's wait
- Binary search k between 1 and n
- Handle unsorted input and the empty case
- Give overall complexity O(n log n log n)
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would the answer change if requests could be routed to any idle replica instead of FIFO order?
- What if service time depends on prompt length and is only known after the fact?
- How would you turn this offline answer into an autoscaling policy?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of (arrival, duration) and W. Requests are served in arrival order; each goes to the replica with the earliest free time and starts at max(arrival, free). Wait is start - arrival. ...
High-Level Design
For a fixed k, a min-heap of replica free times simulates the queue in O(n log k). With n replicas every request starts on arrival, so the answer is in [1, n]. Monotonicity: by induction on requests...