Serving Open LLMs in Production: vLLM, Ollama, llama.cpp and TGI
How to self-host open-weight LLMs: choosing a serving engine, continuous batching, PagedAttention, OpenAI-compatible APIs, GPU sizing and scaling.
Published December 1, 2026
Running an open-weight model on your laptop is easy; serving it to hundreds of concurrent users with good latency and cost is a different job. Serving engines differ in throughput, hardware support and operational features. This guide covers the main options and the concepts that determine performance.
The concept
Throughput on GPUs depends heavily on batching. Continuous batching (used by vLLM, TGI and others) adds new requests to the running batch as soon as slots free up, instead of waiting for a whole batch to finish. PagedAttention, introduced by vLLM, manages the KV cache in pages like virtual memory, reducing waste so more concurrent sequences fit in GPU memory.
Ollama and llama.cpp prioritise ease of use and broad hardware support (CPU, Apple Silicon, consumer GPUs) with GGUF models; they are excellent for development, internal tools and modest traffic. vLLM, SGLang and Hugging Face TGI target high-throughput GPU serving. Most engines expose an OpenAI-compatible HTTP API, so application code can switch between hosted and self-hosted models easily.
Serving engines
| Engine | Best for | Hardware | Notes |
|---|---|---|---|
| Ollama | Dev machines, small internal services | CPU, Apple Silicon, GPUs | Simple CLI, model library, GGUF |
| llama.cpp server | Lightweight, portable serving | CPU/GPU, edge devices | Fine-grained control |
| vLLM | High-throughput GPU serving | NVIDIA/AMD GPUs and others | PagedAttention, continuous batching |
| SGLang | High-throughput, structured generation | GPUs | Fast prefix caching |
| TGI (Hugging Face) | Production serving in HF ecosystem | GPUs | Integrated with HF tooling |
Why batching matters
Production architecture
Practical examples
Start vLLM with an OpenAI-compatible API
Then point any OpenAI SDK at it.
vllm serve Qwen/Qwen2.5-7B-Instruct --max-model-len 16384 --gpu-memory-utilization 0.9
curl http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model":"Qwen/Qwen2.5-7B-Instruct","messages":[{"role":"user","content":"Hello"}]}'Same client, different backend
Switching between hosted and self-hosted is a base URL change.
from openai import OpenAI
client = OpenAI(base_url="http://vllm.internal:8000/v1", api_key="unused")Kubernetes GPU request
Schedule inference pods onto GPU nodes.
resources:
limits:
nvidia.com/gpu: 1
memory: 48GiCommon mistakes
- Benchmarking with a single request and ignoring concurrency.
- Sizing GPUs for weights only, forgetting KV cache for long contexts and many users.
- Exposing inference servers without authentication or rate limits.
- Using a dev-oriented engine for high-traffic production without load testing.
Key takeaways
- Continuous batching and paged KV cache drive GPU throughput.
- Ollama/llama.cpp for ease and portability; vLLM/SGLang/TGI for scale.
- OpenAI-compatible APIs make backends swappable.
- Put a gateway in front for auth, limits and observability.
FAQ
Is self-hosting cheaper than APIs?
At high, steady utilisation it can be; at low or spiky traffic, hosted APIs are usually cheaper once you include GPU idle time and operations.
What latency metrics matter?
Time to first token (responsiveness) and tokens per second per user (streaming speed), plus overall throughput.
Can I serve multiple models on one GPU?
Small models can share a GPU; engines and orchestrators support multi-model serving and LoRA adapter swapping.