The interview question

Serve multiple ML models with predictable latency while keeping infrastructure cost under control.

Balance deadlines, batching, version compatibility, and rollback across shared inference infrastructure.

01. Define the service contract

Specify input schema, output meaning, model version, deadline, and fallback for each endpoint. Separate online requests from asynchronous batch work. A shared platform should not let a low-priority bulk job consume all capacity needed for an interactive ranking request.

A baseline architecture uses a router, bounded per-model queues, versioned workers, and an artifact registry. Model loading and warm-up happen before a worker becomes eligible for traffic. Readiness should test whether the worker can serve the requested version, not just whether its process is alive.

02. Budget the complete request

Admission & routing
Bounded queue
Model workers

Suppose the illustrative deadline is 100 ms: feature retrieval uses 20 ms, queueing 10 ms, inference 50 ms, and response processing 10 ms, leaving 10 ms margin. These are proposed budgets to measure, not guaranteed timings. A faster inference kernel does little if requests spend most of their time waiting.

Batching can improve throughput but adds queueing delay. Bound batch size and wait time, group compatible shapes and versions, and cancel work that can no longer meet a useful deadline. Report queue latency separately from execution latency.

03. Version everything that affects meaning

Package preprocessing, model weights, tokenizer or vocabulary, calibration, and output schema together. A rollback of weights alone may be invalid if the feature mapping has changed. Use immutable artifacts and an explicit compatibility manifest.

Shadow traffic can reveal errors and latency without using the new outputs for decisions, but it still consumes resources and handles real data. Canary a small authorized traffic slice, compare technical and outcome metrics, and retain a rapid route back to a working version.

04. Handle overload and noisy neighbors

Admission control protects the system before queues become unbounded. Isolate expensive models, set per-tenant limits, and use autoscaling signals that include queue delay and model load time. A worker that takes minutes to load cannot rescue a seconds-long spike by itself.

Follow-up: retries double traffic during an outage. Use deadlines, bounded retries, backoff, and clear ownership of retry policy. For a read-only inference call, duplicate execution may waste resources even if outputs have no direct side effects. The caller still needs an explicit response when all attempts fail.

Practice the follow-up

Self-review

Explain why doubling batch size can improve throughput while making the user experience worse.

Connect this to admission control.

For language-model workloads, continue with streaming LLM inference: token budgets, cache memory and partial responses.

Sources & further reading

Google SRE: handling overload; Dean and Barroso: The Tail at Scale. The interview scenario, calculations, and proposed design choices are illustrative.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.