Back to All Guides
AI Engineering9 min readPublished: August 16, 2026Updated: August 16, 2026

Self-Hosting Open-Source LLMs: High-Throughput Inference with vLLM, PagedAttention & Ollama

A practical guide to deploying open-source AI models (Llama 3.3, Mistral, Gemma 2) on Linux and local hardware: comparing vLLM's PagedAttention throughput with Ollama's local developer workflow.

Vyuhantrix Team
Vyuhantrix Team
AI & Systems Engineering · Vyuhantrix

Why Self-Host Open-Source Models?#

  • Strict Data Sovereignty: Zero user data transmitted to third-party cloud providers.
  • Fixed Infrastructure Costs: Predictable GPU server pricing rather than pay-per-token pricing at massive request volumes.
  • Zero Rate Limits: Unlimited throughput constrained only by dedicated GPU hardware.
  • Custom Quantization & Offline Execution: Running models in isolated air-gapped VPCs or edge hardware.

This tutorial contrasts two premier self-hosting tools: Ollama for local development and vLLM for high-concurrency production inference.


1. Local Developer Workflow: Zero-Config Deployment with Ollama#

Ollama bundles model weights, runtime execution, and GPU quantization into a clean, Docker-like CLI.

Quick Start on macOS / Linux:

bash
# 1. Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# 2. Run Google Gemma 2 (9B parameter model with 4-bit quantization)
ollama run gemma2:9b

# 3. Pull Llama 3.3 70B for high-capability local reasoning
ollama pull llama3.3:70b

Integrating with Node.js via OpenAI-Compatible API: Ollama exposes a drop-in OpenAI-compatible REST server on port `11434`:

typescript
import OpenAI from "openai";

// Connect standard OpenAI SDK directly to local Ollama daemon
const localAI = new OpenAI({
  baseURL: "http://localhost:11434/v1",
  apiKey: "ollama", // Required by SDK but ignored by Ollama
});

async function askLocalModel() {
  const completion = await localAI.chat.completions.create({
    model: "gemma2:9b",
    messages: [
      { role: "system", content: "You are a senior Linux systems engineer." },
      { role: "user", content: "Explain how PagedAttention reduces VRAM fragmentation in LLM inference." }
    ],
    temperature: 0.2,
  });

  console.log(completion.choices[0].message.content);
}

2. Production High-Throughput Inference with vLLM & PagedAttention#

While Ollama is optimized for single-user interactive use, vLLM is engineered for high-concurrency production workloads handling hundreds of parallel requests.

The Problem: Key-Value (KV) Cache Memory Fragmentation During LLM generation, intermediate key-value attention tensors are stored in GPU VRAM for every active request. Traditional inference frameworks allocate contiguous memory blocks, leading to **60–80% wasted GPU memory** due to memory fragmentation and unpredictable generation lengths.

The Solution: PagedAttention vLLM implements **PagedAttention**, inspired by operating system virtual memory paging: - Divides the KV cache into small, non-contiguous physical memory blocks. - Allocates memory dynamically as tokens are generated. - Increases serving throughput by **2x to 4x** compared to standard HuggingFace pipelines.

Launching vLLM in Production with Docker:

bash
docker run --gpus all \
  -p 8000:8000 \
  --ipc=host \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  vllm/vllm-openai:latest \
  --model google/gemma-2-9b-it \
  --tensor-parallel-size 1 \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.90

3. Tool Comparison: Ollama vs. vLLM vs. TGI#

MetricOllamavLLMHuggingFace TGI
Primary FocusLocal dev, desktop, prototypingHigh-throughput production servingProduction enterprise serving
Memory Enginellama.cpp (GGUF quantization)PagedAttention (Dynamic VRAM paging)FlashAttention-2 + Paged Attention
Multi-GPU Tensor ParallelismLimitedNative (--tensor-parallel-size N)Native
Concurrent ThroughputLow (Sequential priority)Extremely High (Continuous Batching)Very High
Ease of Setup1-line CLI commandDocker / Python virtualenvDocker container

4. Quantization Demystified: GGUF vs. AWQ vs. GPTQ#

Running 70B parameter models in full 16-bit precision requires over 140 GB of VRAM. Quantization reduces weight precision from 16-bit floating point (fp16) to 4-bit or 8-bit integers (int4 / int8) with negligible loss in accuracy:

FormatBest RuntimeGPU RequirementPrecision / QualityIdeal Use Case
GGUF (Q4_K_M)Ollama / llama.cppCPU + Apple Silicon / Single GPUHigh (Minimal perplexity loss)Desktop & local developer workflows
AWQ (Activation-aware)vLLM / TGINVIDIA GPU (Turing / Ampere / Hopper)Highest (Optimized for activations)High-concurrency production serving
GPTQ (4-bit)vLLM / AutoGPTQNVIDIA GPUHighBatch offline inference pipelines
FP8 (8-bit Float)vLLM (Ada / Hopper H100)NVIDIA RTX 4090 / H100 / L40SNear-Zero DegradationEnterprise data centers

5. Production Nginx Reverse Proxy Architecture#

When hosting vLLM behind a microservices architecture, place a hardened Nginx reverse proxy in front to handle SSL termination, rate limiting, and health monitoring:

nginx
upstream vllm_backend {
    server 127.0.0.1:8000 max_fails=3 fail_timeout=10s;
    keepalive 32;
}

server {
    listen 443 ssl http2;
    server_name ai-inference.internal.company;

    ssl_certificate /etc/ssl/certs/ai-cert.pem;
    ssl_certificate_key /etc/ssl/private/ai-key.pem;

    # Enforce streaming compatibility for Server-Sent Events (SSE)
    location /v1/chat/completions {
        proxy_pass http://vllm_backend;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_buffering off; # Essential for real-time token streaming
        proxy_cache off;
        proxy_read_timeout 300s;
    }

    location /health {
        proxy_pass http://vllm_backend/health;
    }
}

6. Key Takeaways for Production Deployments#

  1. Use Ollama for Dev, vLLM for Production: Ollama delivers the fastest time-to-first-token for individual developers, while vLLM provides the continuous batching throughput needed for multi-tenant applications.
  2. Quantize to 4-bit AWQ or 8-bit FP8: You can run a 70B parameter model on a single 48GB GPU (like an NVIDIA RTX 6000 Ada or dual RTX 3090s) with 4-bit AWQ precision.
  3. Disable Proxy Buffering for SSE: When building streaming chat UIs, always set proxy_buffering off in Nginx to ensure tokens stream to users with zero latency!
Article Note & VerificationThis guide was written and reviewed by the Vyuhantrix Team for educational and practical accuracy. For framework-specific breaking changes, verify against the official documentation of the relevant project. Last updated: August 16, 2026. Disclaimer
Tags:#Open Source AI#vLLM#Ollama#Llama 3#Self Hosting#Linux
Vyuhantrix Team

Published by

Vyuhantrix Team

AI & Systems Engineering · Vyuhantrix

Vyuhantrix is an open technology learning platform based in Ahmedabad, India, publishing step-by-step programming tutorials, system design breakdowns, and free developer tools.