Running an open-weight LLM locally is easy.

Serving it efficiently to hundreds of concurrent users is an entirely different engineering problem.

Imagine deploying an LLM on a GPU server and exposing it through an API. Everything works perfectly during development.

But as traffic increases:

  • GPU memory starts filling up.
  • Requests start queuing.
  • Response latency increases.
  • GPU resources become inefficiently utilized.
  • Infrastructure costs start increasing.

How do we solve these problems?

This is where inference engines come into the picture.

1. LLM vs. Inference Engine

An LLM and an inference engine are two different things.

LLM

A Large Language Model consists of a model architecture and trained weights.

Examples include Llama, Qwen, DeepSeek, Mistral, and Gemma.

The model determines capabilities such as reasoning, text generation, and language understanding.

Inference Engine

An inference engine is responsible for executing the model efficiently.

Its responsibilities can include:

  • Loading model weights.
  • Managing GPU memory.
  • Scheduling requests.
  • Batching workloads.
  • Generating tokens.
  • Managing the KV cache.
  • Distributed model execution.

The LLM provides the intelligence. The inference engine determines how efficiently we deliver it.

2. What Inference Engines Are Available?

Not every inference solution is designed for the same workload.

Solution Best suited for
Ollama Local development and prototyping
llama.cpp CPU, edge devices and consumer hardware
Hugging Face Transformers Research and custom ML workflows
vLLM High-throughput production serving
SGLang Shared-prefix workloads and structured generation
TensorRT-LLM NVIDIA-specific performance optimization

Ollama

Ideal for developers who want to run models locally without worrying about complex infrastructure.

For example:

ollama run qwen2.5:7b 

Useful for personal chatbots, local AI development, and proof-of-concept applications.

llama.cpp

Designed for resource-efficient inference, particularly on consumer hardware.

It supports quantized GGUF models, CPU inference, GPU acceleration, and Apple Silicon.

Hugging Face Transformers

Provides flexibility for research, model experimentation, fine-tuning, and custom inference logic.

However, a basic Transformers implementation wrapped inside FastAPI does not automatically provide sophisticated production request scheduling.

SGLang

A high-performance inference framework that uses techniques such as RadixAttention for efficient prefix cache reuse.

Particularly interesting for AI agents, structured generation, and repeated prompt workloads.

TensorRT-LLM

Designed to optimize inference on NVIDIA hardware using optimized kernels, quantization, and distributed execution.

vLLM

Designed for efficient, high-throughput inference, particularly when multiple users or applications share GPU infrastructure.

Let's understand what makes it interesting.

3. Understanding How LLM Inference Works

LLM inference consists of two major phases.

Prefill

The model processes the input prompt and creates the initial KV cache.

This phase is generally compute-intensive and processes input tokens in parallel.

Decode

The model generates output tokens autoregressively.

Each new token depends on previously generated tokens.

This phase is often memory-bandwidth-intensive.

Input Prompt | v Tokenization | v Prefill Phase | v KV Cache | v Decode Phase | v Generated Tokens 

Efficiently scheduling these two phases becomes important when serving multiple users.

4. The KV Cache Problem

During token generation, transformer models repeatedly need the key and value representations of previous tokens.

Instead of recomputing them, inference engines store them in a Key-Value Cache.

This improves inference efficiency but consumes GPU memory.

Consider an illustrative model configuration:

  • 32 transformer layers.
  • 8 KV attention heads.
  • Head dimension of 128.
  • FP16 KV cache.
  • 4,096 cached tokens per request.

The approximate memory requirement is:

KV Cache Memory = 2 × Layers × KV Heads × Head Dimension × Bytes Per Element × Cached Tokens 

For this configuration:

1 request ≈ 512 MiB 10 requests ≈ 5 GiB 20 requests ≈ 10 GiB 

And this is just the KV cache, excluding model weights and runtime overhead.

This is why GPU memory management becomes a major challenge in production LLM serving.

5. Where Does vLLM Shine?

vLLM combines several engineering concepts to improve inference efficiency.

5.1 PagedAttention

PagedAttention is inspired by virtual memory management in operating systems.

Instead of requiring contiguous memory allocation for each request's KV cache, it divides the cache into blocks.

Request A → Block 1 → Block 4 → Block 7 Request B → Block 2 → Block 5 Request C → Block 3 → Block 6 → Block 8 

Blocks can be dynamically allocated as requests generate additional tokens.

Benefits:

  • Reduced memory fragmentation.
  • Reduced unnecessary memory reservation.
  • Better GPU memory utilization.
  • Higher concurrent serving capacity.

If you're familiar with operating system memory paging, the underlying concept should feel familiar.

5.2 Continuous Batching

Imagine three requests arriving at an inference server:

Request A: 50 output tokens Request B: 200 output tokens Request C: 500 output tokens 

With naive static batching, completed requests can leave unused capacity while longer requests continue executing.

Continuous batching allows new requests to enter the active batch as existing requests finish.

Iteration 1: A B C Iteration 2: A B C Iteration 3: D B C Iteration 4: D E C Iteration 5: D E F 

The scheduler dynamically manages requests across generation iterations.

This helps improve GPU utilization and overall throughput.

5.3 Automatic Prefix Caching

Consider an AI application that sends the same system prompt with every request.

Request A: [System Prompt] + [Question A] Request B: [System Prompt] + [Question B] Request C: [System Prompt] + [Question C] 

Instead of repeatedly computing the shared system prompt, vLLM can reuse previously computed KV cache blocks for matching token prefixes.

This is particularly useful for:

  • AI agents.
  • Multi-turn conversations.
  • Repeated system prompts.
  • RAG applications with shared document prefixes.

Prefix caching reduces redundant prefill computation, but new output tokens still need to be generated.

5.4 Chunked Prefill

A large input prompt can interfere with ongoing token generation for other requests.

Chunked prefill divides large prompts into smaller processing chunks.

Large Input Prompt | v Chunk 1 → Chunk 2 → Chunk 3 → Chunk 4 

The scheduler can process these chunks alongside decoding requests.

This helps balance throughput, GPU utilization, and latency.

5.5 Quantization

Quantization reduces the numerical precision used to represent model weights.

For a hypothetical 7-billion-parameter model:

Precision Theoretical weight memory
FP32 28 GB
FP16 / BF16 14 GB
INT8 7 GB
INT4 3.5 GB

These numbers exclude runtime overhead, quantization metadata, and KV cache memory.

vLLM supports multiple quantization formats depending on the model and hardware.

Lower precision can reduce memory requirements, although performance and model quality trade-offs must be evaluated.

5.6 Distributed Inference

When a model is too large for a single GPU, we can distribute its execution.

Tensor Parallelism

Partitions individual model operations across multiple GPUs.

Pipeline Parallelism

Distributes different model layers across GPUs.

Data Parallelism

Runs multiple model replicas to process different requests independently.

These techniques address different model capacity and throughput requirements.

6. Production Architecture

A production inference platform might look something like this:

 Users / AI Applications | v API Gateway / Load Balancer | v Authentication & Rate Limiting | +--------+--------+ | | v v vLLM Replica 1 vLLM Replica 2 | | v v GPU Node GPU Node Supporting Infrastructure: Kubernetes → Orchestration Docker → Containerization Prometheus → Metrics Grafana → Visualization Object Storage → Model Weights 

The inference engine is only one component of the overall architecture.

We still need to manage authentication, autoscaling, observability, model versioning, availability, and infrastructure costs.

7. Let's Deploy vLLM

We can run vLLM using its official Docker image.

Prerequisites:

  • Compatible NVIDIA GPU.
  • Docker.
  • NVIDIA Container Toolkit.
  • Sufficient GPU memory for the selected model.
docker run --gpus all \ --ipc=host \ -p 127.0.0.1:8000:8000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ vllm/vllm-openai:latest \ --model Qwen/Qwen2.5-1.5B-Instruct 

This starts an OpenAI-compatible inference API.

We can send a request using curl:

curl http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "Qwen/Qwen2.5-1.5B-Instruct", "messages": [ { "role": "user", "content": "Explain Kubernetes autoscaling" } ], "max_tokens": 200 }' 

We can also interact with the model using the OpenAI Python SDK.

pip install openai 
from openai import OpenAI client = OpenAI( base_url="http://localhost:8000/v1", api_key="EMPTY" ) response = client.chat.completions.create( model="Qwen/Qwen2.5-1.5B-Instruct", messages=[ { "role": "user", "content": "What is PagedAttention?" } ] ) print(response.choices[0].message.content) 

For production, pin the Docker image version, configure authentication, restrict network access, and benchmark the workload before exposing the service.

8. When Should We Avoid vLLM?

Just because vLLM is designed for production workloads doesn't mean we should use it everywhere.

Consider simpler alternatives when:

  • Developing locally on a laptop.
  • Building a personal AI chatbot.
  • Creating a proof of concept.
  • Serving a single user with minimal traffic.
  • Running models on resource-constrained hardware.

For these workloads, Ollama or llama.cpp may be more practical.

vLLM can serve a single user, but its concurrency-oriented optimizations may provide limited benefits for that workload.

Don't introduce infrastructure complexity before you actually need it.

9. When Should We Consider vLLM?

vLLM becomes particularly valuable for:

  • Multi-user AI SaaS platforms.
  • Enterprise RAG applications.
  • Large-scale AI agent platforms.
  • High-concurrency inference APIs.
  • Shared GPU infrastructure.
  • High-throughput batch inference.

The objective is not necessarily to generate tokens faster for a single user.

It is to serve the overall workload efficiently while maintaining acceptable latency.

10. What Should We Monitor in Production?

As a DevOps or infrastructure engineer, monitoring GPU utilization alone is not enough.

Metric Purpose
TTFT Time until the first token arrives
TPOT Average time per output token
Throughput Tokens generated per second
Queue length Requests waiting for execution
KV cache utilization Cache memory consumption
Prefix cache hit rate Effectiveness of cache reuse
P95/P99 latency Tail latency
Cost per million tokens Infrastructure cost efficiency

vLLM exposes Prometheus-compatible metrics through its metrics endpoint.

curl http://localhost:8000/metrics 

These metrics can be collected using Prometheus and visualized through Grafana.

Autoscaling decisions should consider request queues, latency, and workload characteristics alongside GPU utilization.

11. Is vLLM Always the Best Choice?

No.

Many competing inference engines implement similar optimization techniques.

The right choice depends on:

  • Available hardware.
  • Model architecture.
  • Concurrent request volume.
  • Prompt and output lengths.
  • Latency requirements.
  • Infrastructure budget.
  • Operational complexity.

Benchmark representative workloads rather than relying exclusively on published performance comparisons.

Final Thoughts

Serving LLMs in production is not just an AI problem.

It's a combination of operating system concepts, memory management, resource scheduling, distributed computing, performance engineering, and infrastructure optimization.

This is what makes AI infrastructure particularly interesting from a DevOps perspective.

The model is only one part of the equation. The infrastructure delivering it matters just as much.

Choose your inference engine based on your workload, not its popularity.

Don't architect for a thousand concurrent users when you're serving just one.

References

What's your preferred inference engine for serving open-weight LLMs?

Are you using vLLM, SGLang, Ollama, or something else? I'd love to hear about your experience in the comments.