Back to blog

Open-Source LLM Deployment Architecture: vLLM, Ollama & SGLang (2026)

How to architect and diagram open-source LLM deployment systems. Covers vLLM PagedAttention, Ollama local dev, SGLang structured generation, llama.cpp CPU inference, and production multi-model serving — with AI prompt templates.

R
Ryan·Senior AI Engineer
·

Open-source LLMs — Llama 3, Mistral, Qwen 2.5, Gemma 3, DeepSeek V3 — have reached production-quality performance across most tasks in 2026. Running these models at scale requires purpose-built inference servers that handle batching, KV cache management, quantization, and multi-GPU tensor parallelism. The inference serving landscape has consolidated around a few dominant frameworks: vLLM for high-throughput production serving, SGLang for structured output and agentic workloads, Ollama for local development, and llama.cpp for CPU and edge deployments.

This guide covers the architecture of each framework, key concepts for your architecture diagram, and prompt templates for diagramming production open-source LLM deployments.

vLLM: high-throughput production inference

vLLM is the most widely deployed open-source LLM inference server for production workloads. Its two core innovations are PagedAttention (treating the KV cache like virtual memory with pages, eliminating fragmentation and enabling 10-24x more throughput than naive implementations) and continuous batching (dynamically grouping incoming requests into batches as they arrive, rather than waiting for a fixed batch to fill).

Key vLLM architecture components

  • LLM Engine: The core scheduling and execution loop — receives requests, schedules them into batches, runs forward passes on GPU
  • Block Manager: Manages the paged KV cache — allocates, swaps, and frees KV blocks across GPU and CPU memory
  • Worker processes: One worker per GPU (or tensor-parallel group), each running a model shard and communicating via NCCL
  • OpenAI-compatible API: vLLM exposes a REST API compatible with the OpenAI Chat Completions and Embeddings endpoints — drop-in replacement
"Production vLLM deployment on AWS. Load balancer: AWS ALB routing to 3 vLLM instances. Each vLLM instance: AWS p4d.24xlarge (8× A100 80GB GPUs), running Llama-3-70B-Instruct with tensor parallelism=8 (all 8 GPUs per instance), vLLM v0.6, PagedAttention enabled, continuous batching, max-model-len=8192. KV cache: GPU memory (split between model weights and KV pages), overflow pages swapped to NVMe SSD. API: OpenAI-compatible REST endpoint on port 8000. Autoscaling: AWS Auto Scaling Group scales instances based on GPU memory utilization and request queue depth (custom CloudWatch metric). Model storage: model weights on Amazon S3, pulled to EFS on instance launch and cached locally. Monitoring: Prometheus scrapes vLLM metrics (token throughput, KV cache utilization, request latency P50/P99, queue depth), Grafana dashboards. Show: vLLM instance internals (LLM Engine, Block Manager, Workers), ALB load balancing across 3 instances, autoscaling trigger, and S3 model storage path."

SGLang: structured generation and agentic workloads

SGLang (Structured Generation Language) is optimized for workloads that require constrained decoding — JSON schema enforcement, regex matching, grammar-constrained generation — and for agentic use cases where the same context is reused across many generation calls. Its RadixAttention mechanism reuses KV cache prefixes shared across multiple requests, making it significantly more efficient than vLLM for multi-turn agent loops and batch evaluation tasks.

"SGLang deployment for structured data extraction pipeline. Input: 50,000 documents/hour from S3. Processing: SGLang server (4× H100 80GB, Qwen2.5-72B-Instruct, tensor_parallel=4) with JSON schema-constrained decoding (extracts: entity_name, date, amount, category from financial documents). RadixAttention enabled — system prompt and extraction schema shared across all requests, prefix cached. Request batching: upstream FastAPI service batches 64 documents per call, sends to SGLang via OpenAI-compatible API. Output: structured JSON arrays written to S3 and indexed in Elasticsearch. Queue: Amazon SQS for backpressure management. Show the batch pipeline from S3 → SQS → FastAPI batcher → SGLang structured generation → S3 output, with RadixAttention prefix sharing annotated."

Ollama: local development and edge deployment

Ollama packages model weights, configuration, and the inference engine into a single binary with a clean REST API. It's the dominant tool for running LLMs locally (Mac, Linux, Windows with GPU or CPU), development workflows, and edge deployments where cloud API calls are not viable due to latency, cost, or privacy. Ollama supports GGUF quantized models via llama.cpp under the hood, plus a growing set of natively supported architectures.

"Local AI development environment with Ollama. Developer machine: MacBook Pro M4 Max (128GB unified memory). Ollama running locally, serving: (1) llama3.2:latest for general chat (8B, Q4_K_M quant, ~5GB), (2) nomic-embed-text for embeddings (local RAG), (3) codellama:13b for code completion (Q4_K_M). Integration: VS Code extension (Continue.dev) calls Ollama API for inline code suggestions. Local RAG pipeline: documents loaded from ~/Documents, chunked with LangChain, embedded via nomic-embed-text through Ollama, stored in local ChromaDB. Query path: Continue.dev or Python script → Ollama REST API (localhost:11434) → GGUF inference → response. Show: Ollama as the central inference hub, the three model instances, VS Code integration, and the local RAG pipeline."

Inference serving framework comparison

FrameworkBest forKey featureHardware
vLLMHigh-throughput production servingPagedAttention, continuous batchingNVIDIA A100/H100, AMD MI300
SGLangStructured output, agentic loopsRadixAttention, constrained decodingNVIDIA H100, A100
OllamaLocal dev, edge deploymentOne-binary install, GGUF supportApple Silicon, NVIDIA, CPU
llama.cppCPU inference, resource-constrainedGGUF quantization, CPU optimizedCPU (x86, ARM), Apple Silicon
TGI (HuggingFace)HuggingFace ecosystem integrationFlash Attention 2, speculative decodingNVIDIA A100/H100

Multi-model serving with an LLM proxy

Production systems often need to route requests to different models based on task type, cost, latency, or capability. An LLM proxy (LiteLLM, AI Gateway) sits in front of multiple inference backends and provides a unified OpenAI-compatible API surface. Your architecture diagram should show the proxy as the single entry point, with routing logic and backend connections to both self-hosted vLLM/SGLang instances and external API providers.

"Multi-model LLM routing architecture. LiteLLM proxy (deployed on AWS ECS, OpenAI-compatible API): routes based on model alias in request. Backends: (1) vLLM cluster (3× p4d.24xlarge, Llama-3-70B) for high-quality generation — alias: 'llama-70b-local', (2) Ollama on dev EC2 instances for low-cost testing — alias: 'llama-8b-dev', (3) Anthropic Claude API (claude-sonnet-4-6) for complex reasoning — alias: 'claude-sonnet', (4) OpenAI API (gpt-4o) as fallback — alias: 'gpt4o-fallback'. Routing rules: default → vLLM Llama-70B; on vLLM error → claude-sonnet; requests with 'model: gpt-4o-mini' → Ollama dev; cost budget exceeded → Ollama dev. LiteLLM tracks spend per API key. Show proxy as central router, backend connections, routing rules, and cost tracking."

Frequently asked questions about open-source LLM deployment

What is vLLM and how does PagedAttention work?

vLLM is an open-source LLM inference server that achieves high throughput through PagedAttention — a memory management technique that treats the KV cache (the key-value tensors the transformer computes during generation) like virtual memory in an OS. Instead of pre-allocating a contiguous memory block per request (which wastes GPU memory due to fragmentation), PagedAttention stores KV cache in fixed-size "pages" that can be allocated, shared, and reclaimed dynamically. This allows vLLM to batch far more requests in parallel, achieving 10–24× higher throughput than naive implementations.

How many GPUs do I need to serve a 70B parameter model?

A 70B parameter model in bfloat16 requires ~140GB of GPU memory for model weights alone. The minimum viable configuration is 2× H100 (80GB each, tensor parallel=2) for model weights with minimal KV cache. For production throughput (handling concurrent requests), 4× H100 or 4× A100 (80GB) is more practical, leaving enough memory for KV cache. Using 4-bit quantization (GPTQ, AWQ) reduces weights to ~35GB, making a single A100 80GB viable for development.

When should I use self-hosted LLMs vs the Anthropic or OpenAI API?

Self-hosted open-source LLMs make sense when: (1) your data cannot leave your infrastructure (healthcare, finance, government), (2) you have extremely high token volume where the cost delta justifies GPU investment (typically >$50K/month in API spend), (3) you need guaranteed SLAs without rate limits or outage dependency, or (4) you need fine-tuning on proprietary data. For most teams, commercial APIs are more cost-effective until one of these thresholds is hit.

Related guides: LLM architecture diagrams, AI gateway architecture, RAG architecture diagram, and LLM deployment use cases.

Ready to try it yourself?

Start Creating - Free