Back to all posts

Self-Hosting LLM Inference with vLLM (and When Not To)

Savinay Kumar

The default for shipping an LLM feature is a hosted API, and that is usually correct. But once a workload becomes high volume, latency-sensitive, or privacy-bound, the per-token bill and the rate limits start to hurt. That is when self-hosting earns its place. A system can combine hosted models such as Gemini with self-hosted vLLM, routing workloads according to capability, demand, and operating cost.

This post outlines an illustrative deployment approach and the tradeoffs to consider. It does not describe a specific employer deployment.

Why vLLM specifically

A naive model server processes one request at a time and wastes most of the GPU. vLLM's two ideas fix that:

The practical result is far higher throughput per GPU than a hand-rolled server, with an OpenAI-compatible endpoint so the application code barely changes.

This illustrative command shows configuration concerns; model availability, quantization compatibility, and flags should be checked against the installed version:

vllm serve meta-llama/Llama-3.1-8B-Instruct \
  --gpu-memory-utilization 0.90 \
  --max-model-len 8192 \
  --tensor-parallel-size 1 \
  --quantization awq

The memory math you cannot skip

A GPU's memory holds three things: the model weights, the KV cache for in-flight requests, and activation overhead. Weights are fixed by the model and the quantization. Whatever is left becomes KV cache, and the KV cache is what determines how many concurrent requests and how long a context you can serve.

This is why --gpu-memory-utilization and --max-model-len are the two knobs that matter most. Push utilization too high and you get out-of-memory crashes under load; set it too low and you waste the card. Quantization (AWQ or GPTQ) shrinks the weights so more room is left for cache, usually at a quality cost small enough to be invisible for routine tasks.

Running it on Kubernetes

One possible architecture places vLLM in a GPU-backed Kubernetes deployment, such as on GKE. Operational considerations include:

When hosted still wins

Self-hosting is infrastructure, and infrastructure has a carrying cost. Hosted models may be more suitable in these situations:

The honest test is total cost of ownership, GPU and on-call and engineering time included, not just the headline price per million tokens. Self-host the predictable, high-volume core where the math clearly wins, and route everything else to a hosted model. The gateway in front makes that routing a config change, not a rewrite.