← Microsoft Interview Insights
This question sprawled in every direction and I don't think I managed it well at first.
Start by clarifying the SLA (e.g., p99 latency target) and workload characteristics, then propose a layered serving stack (load balancer, model server, hardware accelerators) and systematically break down the end-to-end latency budget across components. Discuss optimizations like batching, caching, model quantization, and autoscaling, and explain how to monitor and mitigate tail latency using techniques like hedged requests and graceful degradation.
Pro tip: Emphasize that tail latency is often caused by queuing and cold starts, so you'd design for predictable performance under load by pre-warming instances, using priority queues, and setting aggressive timeouts with fallbacks. Also, mention that you'd instrument every layer with distributed tracing to pinpoint SLA breaches quickly.
Ask about the SLA (e.g., p99 < 100ms), request rate, model size, and hardware availability. Confirm whether the model is online or batch, and any cost or compliance constraints.
Propose a layered architecture: load balancer, API gateway, model server (e.g., Triton, TensorFlow Serving), and hardware (GPU/CPU). Include autoscaling, health checks, and a fallback path for failures.
Allocate time to each component: network (10ms), preprocessing (5ms), inference (50ms), postprocessing (5ms), etc. Ensure the sum meets the SLA with headroom for variability.
Discuss techniques like dynamic batching, model quantization/pruning, caching frequent requests, using faster hardware, and optimizing preprocessing with vectorization.
Implement monitoring (p50/p95/p99), distributed tracing, and alerting. Use hedged requests, timeouts, retries with backoff, and graceful degradation (e.g., fallback to simpler model). Conduct load testing and chaos engineering.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.