Self-hosted serving stack

In one sentence

An inference engine (vLLM, SGLang, TensorRT-LLM) does the batching and KV-cache work on the GPUs; a platform layer (Kubernetes, KServe, Ray Serve, Dynamo) routes, scales on queue depth and hides minutes-long cold starts.

Analogy: A restaurant: the engine is the chef cooking many orders at once on one stove; the platform is the manager who watches the ticket queue and opens a second kitchen, which takes 20 minutes to heat up.

Engines batch on the GPUs; the platform routes by prefix, scales on queue depth and pre-stages weights to shorten cold starts.

How it works

  • vLLM is the default engine; SGLang shines on shared prefixes; TensorRT-LLM is often fastest but harder to run.
  • Don't autoscale on CPU or GPU util%: it reads ~100% even at batch 1.
  • Hide cold starts with a warm floor of replicas and weights pre-staged on the nodes.
  • Keep tensor parallelism inside one NVLink node; across nodes, use pipeline parallelism.
  • Multi-LoRA serves dozens of fine-tunes from one copy of the base model.

Check yourself

Answer to mark it learned; your answers aren't scored.

Your vLLM fleet's HPA scales on CPU. On Monday mornings traffic triples: CPU sits at ~15% and requests wait 40 s in the queue, yet nothing scales. Which signal should drive autoscaling?

Go deeper

Full explanation

A self-hosted stack has two layers.

The engine runs one model on one or more GPUs: Continuous batching, PagedAttention & vLLM KV memory, prefix caching and an OpenAI-compatible API.

  • vLLM: the default; widest model and hardware support, multi-LoRA.
  • SGLang: RadixAttention keeps shared prefixes in a radix tree; strong for agents, few-shot and multi-turn traffic.
  • TensorRT-LLM: NVIDIA's optimized kernels and FP8/FP4 paths; often the fastest on NVIDIA hardware, more complex to operate.
  • TGI: Hugging Face's server, in maintenance mode since late 2025 (repo archived March 2026); HF itself now points to vLLM and SGLang.
  • llama.cpp / Ollama: quantized GGUF models on laptops and CPUs; for development, not fleets.

The platform turns replicas into a service: Kubernetes GPU node pools, KServe or Ray Serve for deploys and autoscaling, and NVIDIA Dynamo or llm-d for KV-aware routing and disaggregated prefill/decode.

Three rules that differ from web serving:

  1. Scale on queue depth or KV-cache usage, not CPU. CPU says nothing, and GPU util% reads ~100% even at batch 1.
  2. Cold starts take minutes. A GPU node, a ~10 GB image and 140 GB of weights: keep a warm floor and pre-stage weights.
  3. Tensor parallelism stays inside one NVLink node; across nodes, use pipeline parallelism.

Multi-LoRA serves dozens of fine-tunes from one copy of the base model.

Code vLLM on Kubernetes, autoscaled on queue depth
yamlvLLM on Kubernetes, autoscaled on queue depth
# 70B in BF16 = ~140 GB of weights -> TP=4 on 80 GB GPUs leaves room for KV cache
apiVersion: apps/v1
kind: Deployment
metadata: { name: llama-70b }
spec:
  selector: { matchLabels: { app: llama-70b } }
  template:
    metadata: { labels: { app: llama-70b } }
    spec:
      nodeSelector: { pool: h100 }            # dedicated GPU node pool
      containers:
        - name: vllm
          image: vllm/vllm-openai:v0.10.1     # pin it; never :latest
          args: ["--model", "/models/llama-3.3-70b-instruct",  # pre-staged on local NVMe
                 "--served-model-name", "llama-70b", "--tensor-parallel-size", "4",
                 "--enable-prefix-caching", "--enable-lora", "--max-loras", "8"]
          resources: { limits: { nvidia.com/gpu: 4 } }
          # Loading weights takes minutes: a short liveness probe would kill it mid-load
          startupProbe: { httpGet: { path: /health, port: 8000 }, periodSeconds: 10, failureThreshold: 90 }
---
# Scale on queued requests: CPU stays flat while the GPUs saturate
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata: { name: llama-70b }
spec:
  scaleTargetRef: { name: llama-70b }
  minReplicaCount: 2          # warm floor: a cold replica needs minutes
  maxReplicaCount: 8
  triggers:
    - type: prometheus
      metadata:
        serverAddress: http://prometheus.monitoring:9090
        query: sum(vllm:num_requests_waiting{model_name="llama-70b"})
        threshold: "8"        # target ~8 waiting requests per replica
Real example

A team serves Llama 3.3 70B for an internal assistant on 2 replicas of 4× H100. Every Monday at 9:00 traffic triples. Their HPA watched CPU, which sat at ~15% while requests queued for 40 s, so nothing scaled. They moved to KEDA on vllm:num_requests_waiting, but each new replica took ~12 minutes (node provisioning, image pull, 140 GB download from S3). The final fix: weights pre-staged on node NVMe (load drops to ~3 minutes), a scheduled scale-up at 8:30, and the queue-based scaler for the rest of the day.

Trade-offs +3 · −3

+ You gain

  • OpenAI-compatible engines make a self-hosted model a drop-in behind existing client code.
  • Full control of latency, batching, quantization and which fine-tunes run.
  • Prefix caching and multi-LoRA let one fleet serve many tenants and model variants.

− You pay

  • You own GPU capacity, drivers, CUDA versions, engine upgrades and the 3 a.m. page.
  • Minutes-long cold starts force a warm floor of idle, billed GPUs.
  • Engines move fast: flags, metric names and defaults change between minor versions.

Use it when

You have already decided to self-host (data residency, custom weights, steady high volume) and need predictable latency for open models in production.

Avoid it when

Low or spiky traffic, a team without GPU and Kubernetes ops experience, or when a managed endpoint for the same open model (Bedrock, Vertex, an inference provider) meets your constraints.

Numbers to know 5
  • Weights ≈ params × bytes: 70B in BF16 ≈ 140 GB → at least 2× 80 GB GPUs, usually 4 for KV-cache headroom.
  • vLLM pre-allocates 90% of GPU memory by default (--gpu-memory-utilization 0.9), mostly for KV cache.
  • SGLang paper (2023): up to 6.4× higher throughput than prior systems on structured, prefix-sharing workloads.
  • H100 NVLink ~900 GB/s vs ~50 GB/s for a 400 Gb/s NIC: why tensor parallelism stays inside a node.
  • Cold-start floor: 140 GB at ~1 GB/s is ~2.3 minutes for the bytes alone, before node provisioning and warm-up.
Common pitfalls 4
  • Autoscaling on CPU or GPU util%: neither tracks how full the batch is. Use queue depth, KV usage or TTFT.
  • Liveness probes that kill a replica still loading its weights: use a long startupProbe.
  • Scaling to zero for an interactive product: the first user after a quiet period waits minutes.
  • Tensor parallelism across nodes over Ethernet: the per-layer all-reduce eats the gain. Use pipeline parallelism between nodes.
Interview questions 3

Answer out loud first, then reveal.

How would you autoscale a self-hosted LLM fleet?Show answer

Not on CPU, and not on GPU utilization: nvidia-smi shows ~100% even at batch 1. I scale on signals that track saturation: requests waiting in the engine queue, KV-cache usage and p95 TTFT against the SLO. Because a new replica needs minutes (node, image, 140 GB of weights), I keep a warm floor sized for normal peak, pre-stage weights on local NVMe, schedule scale-ups for known peaks and let the queue-based scaler handle the rest. Scale-down is slow and conservative to avoid flapping.

vLLM, SGLang or TensorRT-LLM: which do you pick?Show answer

I default to vLLM: widest model support, OpenAI-compatible server, prefix caching, multi-LoRA and the biggest community, so new models usually land there first. I pick SGLang when traffic shares long prefixes (agents, few-shot templates, multi-turn chat) because RadixAttention reuses them aggressively. TensorRT-LLM when I run NVIDIA at large scale and the extra throughput per GPU pays for the extra build and ops complexity. Either way I benchmark on my own prompt and output length distribution at my latency SLO, not on a vendor chart.

You must serve 40 customer-specific fine-tunes of an 8B model. How?Show answer

Not with 40 deployments. I train LoRA adapters and serve them on one base model with multi-LoRA (vLLM --enable-lora, S-LoRA-style batching). Adapters are tens of MB, so many fit next to one 16 GB copy of the base, and requests for different adapters batch together; the request picks its adapter by model name. The trade-off is some per-token overhead versus a merged model, so if one tenant dominates traffic, it gets a dedicated merged deployment.