---
title: You are moving about 3,000 concurrent coding agents from a managed API to a self-hosted open model served with vLLM on…
url: https://gurkanozkan.ai/learn/questions/recent-b-mlops-02/
markdown: https://gurkanozkan.ai/learn/questions/recent-b-mlops-02.md
kind: question
role: ML engineering
stage: System design
difficulty: Hard
json: https://gurkanozkan.ai/api/learn/questions/recent-b-mlops-02.json
robots: noindex
---

# You are moving about 3,000 concurrent coding agents from a managed API to a self-hosted open model served with vLLM on Kubernetes. Why does a standard Kubernetes Service balance this traffic badly, and what would your routing, scheduling and model-upgrade design look like?

ML engineering · System design · Hard

## Answer

*Model answer, written in a candidate's voice*

### In short

- Standard Service balances connections, not requests: 3k agents have wildly different prompt/output lengths, so round-robin/least-connections sends long jobs to busy replicas and ignores KV-cache warmth.
- Use an LLM-aware gateway (Gateway API Inference Extension InferencePool with an endpoint picker) that routes on live queue depth, KV/memory use, loaded LoRA adapters and prefix-cache state.
- Add prefix-cache-aware routing and session pinning for multi-turn agent turns; consider KV offloading and prefill/decode disaggregation for long contexts.
- Separate interactive vs batch traffic with criticality/QoS classes, tenant quotas and fairness rather than one undifferentiated pool.
- Upgrade by canarying a new model through the gateway, watching TTFT and per-token latency percentiles, cache hit rate and errors, and draining sessions instead of cutting them.
- Compare total cost and capacity with the managed API: GPU utilisation, headroom, on-call burden and operational risk; self-hosting pays off only with high sustained utilisation and SLO-level reliability.

### In full

A standard Kubernetes Service is the wrong unit of balancing here: it spreads connections or requests roughly evenly, but coding agents differ enormously in prompt and output length, hold KV-cache state, and are better described by queue depth, memory and cache warmth than by connection count, so round-robin will pile long jobs onto already-hot replicas. I would put an LLM-aware gateway in front of vLLM — for example Gateway API Inference Extension InferencePool with an endpoint picker — that routes on live metrics such as queue length, KV/memory utilisation, loaded LoRA adapters and prefix-cache state, rather than on pod health alone. For multi-turn agents I would add prefix-cache-aware routing and session pinning so a turn reuses its warm prefix, and for long contexts I would evaluate KV offloading and prefill/decode disaggregation so long prompts do not monopolise decode workers. I would separate interactive from batch traffic with criticality/QoS classes, tenant quotas and fairness, so a burst of batch jobs cannot starve latency-sensitive agent turns. For upgrades I would canary a new model version through the gateway, watch TTFT and per-token latency percentiles, cache hit rate and errors, and drain sessions rather than cutting them. Finally I would compare this against the managed API on total cost and capacity — GPU utilisation, headroom, on-call burden and operational risk — not just unit price, because self-hosting pays off only when sustained GPU utilisation is high enough to beat per-token pricing and reliability still meets the SLO.

*Corrected by an independent AI reviewer.*

## What a strong answer covers

- Explains why round-robin fails: requests differ hugely in prompt and output length, replicas hold KV-cache state, and load is better measured by queue depth and memory than by connection count.
- Uses an LLM-aware gateway (e.g. Gateway API Inference Extension InferencePool with an endpoint picker) that routes on live metrics such as queue length, memory use and loaded LoRA adapters.
- Adds prefix-cache-aware routing and session pinning so multi-turn agent turns reuse their warm prefix, and considers KV offloading and prefill/decode disaggregation for long contexts.
- Separates priorities: interactive versus batch traffic with criticality or QoS classes and fairness between tenants.
- Plans upgrades: canary a new model version through the gateway, watch TTFT and per-token latency percentiles, cache hit rate and errors, and drain sessions rather than cutting them.
- Compares total cost and capacity with the managed API, including GPU utilisation and on-call burden.

## Common mistakes

- Scaling replicas on CPU utilisation or request count alone.

## Follow-ups

- Cache hit rate falls from 80% to 30% after you double the replica count. Why, and what do you change?

## Topic guides

- [KV cache](https://gurkanozkan.ai/learn/topics/kv-cache.md)
- [LLM inference: decoding, batching, quantisation and speculative decoding](https://gurkanozkan.ai/learn/topics/inference.md)
- [LLM serving: latency, throughput and operations](https://gurkanozkan.ai/learn/topics/serving.md)
- [MLOps and LLMOps](https://gurkanozkan.ai/learn/topics/mlops.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
