Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

vLLM: High-Throughput LLM Serving

By Kokil Thapa | Last reviewed: September 2026

Production teams hit a wall when a single GPU can only serve a handful of concurrent chat users. vLLM: High-Throughput LLM Serving solves that bottleneck with memory-efficient KV-cache management and continuous batching. If you already run Ollama or vLLM locally, the jump to production is mostly about hardware, queueing, and observability—not rewriting your app. This guide covers how vLLM works, how to deploy it, and where it fits next to managed APIs and lighter local runners.

What is vLLM and why does it matter for high-throughput LLM serving?

vLLM is an open-source LLM inference and serving library from the vLLM project. It targets the gap between research notebooks and production APIs. Naive inference loads one request, runs a full forward pass, then frees memory. That pattern wastes GPU cycles when users type, think, or read streamed tokens.

vLLM instead keeps the model resident on GPU. It batches new tokens from many active sequences in one forward pass. Throughput rises because the GPU stays busy. Latency for individual users stays acceptable when batch sizes stay moderate and you cap max sequence length.

In my experience integrating LLM APIs into Laravel and WordPress products, the serving layer—not the prompt—often decides whether a feature survives launch week. A legal-tech portal with document Q&A can look fine in demos. Under twenty simultaneous users, a naive stack queues hard. vLLM is built for that second scenario.

vLLM Serving PipelineClient AppLaravel / JSOpenAI API/v1/chatvLLM EngineSchedulerGPU VRAMPagedAttentionContinuous Batching LoopPrefillDecodeStreamDoneMany requests share one forward pass per decode step
vLLM high-throughput LLM serving pipeline: OpenAI-compatible API, scheduler, and GPU-backed continuous batching

Core features that drive throughput include:

  • PagedAttention — KV cache stored in fixed-size blocks, like virtual memory pages
  • Continuous batching — new requests join an in-flight batch without waiting for others to finish
  • OpenAI-compatible REST API — swap base URLs in existing SDK clients
  • Tensor parallelism and pipeline parallelism — scale one model across multiple GPUs
  • Quantization support — AWQ, GPTQ, FP8, and related formats to fit larger models in VRAM

For background on latency versus throughput trade-offs, see serving LLMs in production. vLLM optimizes the throughput side without ignoring time-to-first-token.

How does PagedAttention enable higher throughput on limited GPU memory?

During autoregressive generation, each token adds key-value tensors to a growing KV cache. That cache often dominates VRAM use—not the model weights. Traditional serving pre-allocates one contiguous buffer per sequence sized to max_model_len. Most conversations never reach that cap. You pay for reserved memory you never touch.

PagedAttention splits the KV cache into blocks. A block table maps logical token positions to physical GPU blocks. When a sequence grows, vLLM allocates another block. When a sequence ends, blocks return to a free list. Fragmentation drops. More concurrent sessions fit on the same card.

Why this beats static allocation

Static allocation is simple to reason about. It also leaves 30–60% of KV memory idle on typical chat workloads. PagedAttention recovers that headroom. On a 24 GB GPU running a 7B model, the difference can be 8 versus 32 concurrent chats depending on context length and batch policy.

PagedAttention KV CacheStatic AllocationReserved max length (mostly empty)UsedPaged BlocksB1B2FreeB3Block table maps tokens to pagesResult: More Concurrent SequencesSame GPU serves 3x–5x more active chatsMemory returned when sessions complete
PagedAttention in vLLM replaces wasteful contiguous KV buffers with reusable memory blocks for high-throughput LLM serving

Continuous batching pairs with PagedAttention. At each decode step, the scheduler picks all sequences that need one more token. It builds a single batched forward pass. Finished sequences leave the batch. New ones enter during prefill. GPU utilization stays high across mixed-length conversations.

Long-context RAG workloads stress KV memory hardest. If your app sends 8K-token document chunks, read long-context LLM strategies before picking max_model_len. Oversizing that parameter wastes blocks even with paging.

How do you install and run vLLM for production serving?

vLLM runs on Linux with NVIDIA CUDA GPUs in most production setups. AMD ROCm builds exist for supported hardware. CPU-only mode is available for smoke tests—not for real throughput targets.

Basic OpenAI-compatible server

Install with pip in a dedicated virtual environment on Ubuntu 22 or 24:

python3 -m venv .venv
source .venv/bin/activate
pip install vllm

python -m vllm.entrypoints.openai.api_server \
  --model meta-llama/Llama-3.1-8B-Instruct \
  --host 0.0.0.0 \
  --port 8000 \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.90

Test with curl against the compatible chat endpoint:

curl http://127.0.0.1:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meta-llama/Llama-3.1-8B-Instruct",
    "messages": [{"role": "user", "content": "Summarize PagedAttention in one sentence."}],
    "max_tokens": 128,
    "stream": true
  }'

Point your OpenAI SDK at vLLM by changing the base URL and supplying any dummy API key if auth is disabled:

from openai import OpenAI

client = OpenAI(
    base_url="http://gpu-server.internal:8000/v1",
    api_key="not-needed"
)

response = client.chat.completions.create(
    model="meta-llama/Llama-3.1-8B-Instruct",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

Streaming responses matter for perceived latency. Your PHP or Laravel front end should consume SSE or chunked JSON the same way it would with OpenAI. See streaming LLM responses with SSE for UI patterns that work behind reverse proxies.

Production hardening checklist

  1. Run vLLM behind Nginx or another reverse proxy with TLS termination and rate limits
  2. Set --gpu-memory-utilization below 1.0 to leave headroom for CUDA context spikes
  3. Pin model revision and vLLM version in your deploy manifest—upgrades can change default kernels
  4. Export Prometheus metrics and log queue depth, prefill time, and decode tokens per second
  5. Configure health checks on /health or a lightweight completion probe
  6. Use a process supervisor or container restart policy—GPU OOM kills the worker hard

For Kubernetes-native serving with autoscaling hooks, compare vLLM sidecars against KServe on Kubernetes. Many teams run vLLM in a single GPU VM first. They move to K8s only when replica count justifies the ops cost.

Production vLLM TopologyNginx + TLSLaravel AppQueue + cacheRedisRate limit keysPrometheusMetrics scrapevLLM GPU Node A8B–13B modelsPort 8000vLLM GPU Node B70B TP=2Port 8000
Typical production layout for vLLM high-throughput LLM serving: TLS proxy, app tier, Redis, metrics, and dedicated GPU workers

Server administration—firewall rules, GPU driver pins, nightly backups—belongs in the same runbook as your web tier. If you host in Nepal or on a budget VPS abroad, Linux system administration and hosting setup should be planned before you promise sub-second chat to stakeholders.

What GPU hardware and tuning knobs matter most for vLLM throughput?

VRAM sets the ceiling. Model weights, KV blocks, and activation buffers all compete for the same pool. A rough planning table helps before you rent cloud GPUs:

Model classPrecisionMin VRAM (serve)Typical cloud costNotes
7B–8B instructFP1616 GB~USD 0.50–1.50/hrGood default for internal tools and RAG
7B–8B instructAWQ / GPTQ 4-bit8–10 GB~USD 0.30–0.80/hrSlight quality trade-off, big memory win
13B–14BFP1628–32 GB~USD 1.50–3.00/hrStronger reasoning, fewer concurrent users
70B4-bit + TP=22× 48 GB~USD 6–12/hrTensor parallel across two GPUs required

Nepal-based teams often compare on-prem workstation GPUs against Singapore or Mumbai cloud regions. A local RTX 4090 at Rs 450,000 (~USD 3,400) can beat recurring cloud bills above Rs 40,000/month (~USD 300) if utilization stays high. Sporadic usage favors pay-per-hour rentals. Read self-hosting LLM options and GPU requirements for a fuller cost model.

Tuning parameters that move the needle

  • --max-num-seqs — caps concurrent sequences; raise until latency SLO breaks
  • --max-model-len — lower this if RAG prompts are short; saves KV blocks
  • --enable-prefix-caching — reuse KV for identical system prompts across users
  • --tensor-parallel-size — split layers across GPUs for models that do not fit on one card
  • --quantization awq — load pre-quantized weights when VRAM is tight

Prefix caching helps products with fixed system instructions—support bots, legal disclaimers, JSON schema reminders. It behaves like a hot cache for prompt prefixes. Application-level caching still matters for identical user queries. Combine both layers as described in caching strategies for high-traffic sites.

Monitor GPU memory with nvidia-smi dmon during load tests. Watch for PCIe bottlenecks when loading large checkpoints from disk. Store models on local NVMe, not network mounts.

How does vLLM compare to Ollama, TGI, and managed LLM APIs?

Pick the serving stack based on team size, traffic shape, and compliance—not GitHub stars alone.

CriteriavLLMOllamaText Generation InferenceManaged API (OpenAI etc.)
Primary strengthMaximum GPU throughputDeveloper convenienceHugging Face ecosystemZero ops, latest models
OpenAI-compatible APIYes, nativePartial / evolvingYesYes (reference)
Multi-GPU scalingStrong (TP / PP)LimitedStrongN/A (provider-side)
Setup complexityMediumLowMedium–highLowest
Best fitProduction self-host at scaleLocal dev and small deploysHF model catalog shopsFast MVP, variable traffic

Ollama wins for laptop prototyping and single-user demos. vLLM wins when concurrent users and GPU dollars dominate. Managed APIs win when you lack GPU ops capacity or need frontier models immediately. Hybrid setups are common: vLLM for steady internal traffic, managed APIs for overflow or fallback.

Compare local runners in Ollama vs LM Studio and running LLMs locally with Ollama and vLLM. For API-only products, choosing an LLM API on cost, speed, and quality covers vendor selection.

Serving Stack DecisionNeed LLM in prod?Dev onlyFew usersSelf-host GPUData stays localNo GPU opsBurst trafficUse OllamaFast iterationUse vLLMHigh throughputManaged APILowest ops
Decision guide: when vLLM high-throughput LLM serving beats Ollama for local dev or managed APIs for zero-ops deploys

How do you integrate vLLM into a Laravel or PHP application safely?

Most PHP stacks should treat vLLM as an HTTP dependency—not embed Python inside FPM workers. Queue long generations. Stream tokens to the browser. Never block an Apache or PHP-FPM child for thirty seconds waiting on GPU output.

A minimal Laravel service class wraps the OpenAI client pointed at vLLM:

<?php

namespace App\Services;

use OpenAI;

class VllmChatService
{
    public function stream(string $prompt, callable $onDelta): void
    {
        $client = OpenAI::client(config('services.vllm.key'));

        $stream = $client->chat()->createStreamed([
            'model' => config('services.vllm.model'),
            'messages' => [
                ['role' => 'system', 'content' => 'You are a concise assistant.'],
                ['role' => 'user', 'content' => $prompt],
            ],
            'max_tokens' => 512,
        ]);

        foreach ($stream as $response) {
            $delta = $response->choices[0]->delta->content ?? '';
            if ($delta !== '') {
                $onDelta($delta);
            }
        }
    }
}

Dispatch heavy jobs to Laravel queues—the same pattern used for email and PDF generation on high-traffic apps. Read scaling Laravel queues for high traffic before you expose LLM endpoints on synchronous routes.

Security and compliance checkpoints:

For structured JSON from models, enforce schemas in PHP after generation. Pair with structured outputs from LLMs and validate payloads with the JSON formatter tool during development.

On a legal-tech portal I built, document summarization ran behind a queue with per-firm rate limits. vLLM sat on a private subnet. The public Laravel app never held GPU credentials. That separation simplified audits and firewall rules.

Full product delivery—RAG pipelines, admin dashboards, billing—maps to AI integration and automation services and API development. Reference implementations appear in client portal projects where secure document workflows matter.

What operational practices keep vLLM reliable under load?

Throughput without observability is a demo, not a service. Treat vLLM like any stateful backend: define SLOs, load-test before marketing launches, and run game days for GPU node failure.

Metrics worth dashboarding

  • Time to first token (TTFT) at p50 and p95
  • Tokens per second per request and aggregate GPU throughput
  • Queue wait time before prefill starts
  • GPU memory used versus gpu-memory-utilization cap
  • HTTP 5xx rate and OOM restart count

Wire alerts into the same channel as database slow-query alerts. LLM regressions show up as rising TTFT long before users complain. LLMOps monitoring and guardrails and shipping LLM apps with LLMOps cover evaluation loops that complement raw metrics.

Load testing should mimic real chat—not uniform random prompts. Mix short questions, 4K RAG contexts, and occasional tool-call rounds. Tools like vllm bench serve (bundled with the project) give baseline numbers. Your app-level test must include PHP queue delay and Redis contention.

Cost control still applies on owned GPUs. Track tokens per customer for billing or quota enforcement. LLM cost optimization translates cleanly to "GPU hours per thousand requests" when you self-host.

Privacy-sensitive workloads—Nepali health, legal, or financial data—often mandate on-prem inference. Pair vLLM with local LLMs for privacy-sensitive apps policy patterns: network isolation, no outbound telemetry, encrypted volumes.

Official references: the vLLM documentation covers CLI flags and supported models, and the vLLM GitHub repository tracks release notes. For the original PagedAttention paper and benchmarks, see the PagedAttention research preprint on arXiv.

Key Takeaways

  • vLLM: High-Throughput LLM Serving wins on concurrent GPU utilization via PagedAttention and continuous batching—not raw model quality.
  • Start with the OpenAI-compatible API server; point existing SDKs at your GPU host with a base URL change.
  • Right-size max-model-len and enable prefix caching before buying a second GPU.
  • Never run long vLLM calls inside PHP-FPM workers—queue, stream, and rate-limit at the app layer.
  • Compare self-hosted vLLM against managed APIs using total cost at your actual queries-per-minute, not sticker hourly rates.
  • Monitor TTFT, queue depth, and OOM restarts from day one; throughput dies silently when KV memory fills.

People Also Ask

Is vLLM faster than Ollama for production traffic?

Yes, for concurrent users on the same GPU. Ollama optimizes developer experience and single-session latency. vLLM optimizes batch throughput with PagedAttention. For a production API serving dozens of simultaneous chats, vLLM typically delivers several times higher tokens per second per dollar.

Does vLLM support streaming and function calling?

vLLM's OpenAI-compatible server supports streaming chat completions. Tool and function calling support depends on model and server version—verify against the model card and current vLLM release notes before relying on it in production agent workflows.

Can you run vLLM without an NVIDIA GPU?

NVIDIA CUDA GPUs are the primary production path. AMD ROCm builds exist for supported cards. CPU backends work for functional testing but do not meet high-throughput LLM serving goals for real user load.

How many users can one vLLM GPU handle?

There is no fixed number. A 24 GB GPU running an 8B model might serve 20–40 short chats or far fewer long RAG sessions. Load test with your prompt length, max-model-len, and latency SLO—the only honest answer for your app.

Ship high-throughput LLM features with the right serving layer

vLLM: High-Throughput LLM Serving is the practical choice when self-hosted inference must carry real concurrent load without multiplying GPU spend. Start from the OpenAI-compatible server, tune memory and sequence limits against your RAG prompts, and keep Laravel or PHP apps thin with queues and streaming. When you need help sizing hardware, wiring private GPU endpoints, or integrating summarization into a production portal, contact us or explore custom software development. For related reading, browse more LLM and infrastructure guides or review production portals where secure workflows come first.

Frequently Asked Questions

vLLM is an open-source LLM inference engine that uses PagedAttention and continuous batching to serve many concurrent chat, RAG, and tool-calling requests on shared GPU memory via an OpenAI-compatible HTTP API.

During autoregressive generation, the KV cache often dominates VRAM, not model weights. Traditional serving pre-allocates one contiguous buffer per sequence sized to max_model_len, leaving 30–60% of KV memory idle on typical chat workloads. PagedAttention splits the cache into fixed-size blocks mapped through a block table, like virtual memory pages. When a sequence grows, vLLM allocates another block; when it ends, blocks return to a free list. Fragmentation drops and more concurrent sessions fit on the same card. On a 24 GB GPU running a 7B model, that can mean 8 versus 32 concurrent chats depending on context length and batch policy.

Naive inference loads one request, runs a full forward pass, then frees memory—wasting GPU cycles while users type or read streamed tokens. vLLM keeps the model resident and, at each decode step, the scheduler picks all sequences needing one more token and builds a single batched forward pass. Finished sequences leave the batch; new ones enter during prefill. GPU utilization stays high across mixed-length conversations. Throughput rises because the GPU stays busy, while individual latency stays acceptable when batch sizes stay moderate and you cap max sequence length.

vLLM runs on Linux with NVIDIA CUDA GPUs in most production setups; AMD ROCm builds exist, and CPU-only mode suits smoke tests only. On Ubuntu 22 or 24, create a virtual environment, run pip install vllm, then start the OpenAI-compatible server with python -m vllm.entrypoints.openai.api_server, specifying model, host, port, max-model-len, and gpu-memory-utilization. Test with curl against /v1/chat/completions using stream true. Point existing OpenAI SDK clients at the vLLM base URL with a dummy API key if auth is disabled. Streaming matters for perceived latency—PHP and Laravel front ends should consume SSE or chunked JSON the same way they would with OpenAI.

Roughly 16 GB VRAM at FP16, or 8–10 GB with AWQ or GPTQ 4-bit quantization. Quantization trades slight quality for a big memory win.

max-num-seqs caps concurrent sequences—raise it until latency SLOs break. max-model-len should match real prompt lengths; oversizing wastes KV blocks even with paging, especially on long-context RAG workloads sending 8K-token chunks. enable-prefix-caching reuses KV for identical system prompts across users, useful for support bots and fixed legal disclaimers. tensor-parallel-size splits layers across GPUs when a model does not fit on one card. quantization awq loads pre-quantized weights when VRAM is tight. Combine prefix caching with application-level caching for identical user queries. Monitor GPU memory with nvidia-smi dmon during load tests and store models on local NVMe, not network mounts.

vLLM targets maximum GPU throughput with strong multi-GPU scaling via tensor and pipeline parallelism and a native OpenAI-compatible API. Ollama wins for developer convenience, laptop prototyping, and single-user demos with limited multi-GPU scaling. Text Generation Inference fits Hugging Face ecosystem shops with strong scaling but medium-to-high setup complexity. Managed APIs like OpenAI offer zero ops and frontier models with lowest setup cost, best for fast MVPs and variable traffic. Pick based on team size, traffic shape, and compliance—not GitHub stars. Hybrid setups are common: vLLM for steady internal traffic, managed APIs for overflow or fallback.

Choose vLLM when concurrent users and GPU dollars dominate—production self-hosting at scale where a naive stack queues hard under twenty simultaneous users. Ollama suits local dev and small deploys. Managed APIs win when you lack GPU ops capacity, need frontier models immediately, or traffic is too sporadic to justify hardware. Many teams run vLLM on a single GPU VM first and move to Kubernetes only when replica count justifies the ops cost. Nepal-based teams often weigh a local RTX 4090 against Singapore or Mumbai cloud regions depending on utilization.

Treat vLLM as an HTTP dependency—never embed Python inside PHP-FPM workers. Queue long generations, stream tokens to the browser, and never block an Apache or PHP-FPM child for thirty seconds waiting on GPU output. Wrap the OpenAI client pointed at vLLM in a service class, dispatch heavy jobs to Laravel queues, and consume streamed deltas in your controller. Strip PII before prompts leave your app, validate tool-call outputs server-side, apply retries and circuit breakers, and log prompt hashes plus latency and token counts—not full user text. On a legal-tech portal I built, vLLM sat on a private subnet while the public Laravel app never held GPU credentials.

Run vLLM behind Nginx or another reverse proxy with TLS termination and rate limits. Set gpu-memory-utilization below 1.0 to leave headroom for CUDA context spikes. Pin model revision and vLLM version in your deploy manifest because upgrades can change default kernels. Export Prometheus metrics and log queue depth, prefill time, and decode tokens per second. Configure health checks on /health or a lightweight completion probe. Use a process supervisor or container restart policy—GPU OOM kills the worker hard. Server administration—firewall rules, GPU driver pins, nightly backups—belongs in the same runbook as your web tier.

A 7B–8B instruct model at FP16 runs roughly USD 0.50–1.50 per hour; 4-bit quantized versions cost USD 0.30–0.80 per hour. A local RTX 4090 at Rs 450,000 (~USD 3,400) can beat recurring cloud bills above Rs 40,000/month (~USD 300) when utilization stays high.

Dashboard time to first token at p50 and p95, tokens per second per request and aggregate GPU throughput, queue wait time before prefill starts, GPU memory used versus the gpu-memory-utilization cap, and HTTP 5xx rate plus OOM restart count. Wire alerts into the same channel as database slow-query alerts—LLM regressions show up as rising TTFT long before users complain. Load testing should mimic real chat: mix short questions, 4K RAG contexts, and occasional tool-call rounds. Use vllm bench serve for baseline numbers, but your app-level test must include PHP queue delay and Redis contention.

Yes. vLLM exposes a native OpenAI-compatible REST API, so you swap the base URL in existing SDK clients and supply any dummy API key if auth is disabled. The server serves /v1/chat/completions with streaming support. Your Laravel, WordPress, or other PHP products can reuse the same OpenAI client libraries pointed at an internal GPU server. This matters because the serving layer—not the prompt—often decides whether a feature survives launch week when concurrent users spike.

Nepali health, legal, or financial data often mandates on-prem inference. Pair vLLM with network isolation, no outbound telemetry, and encrypted volumes. Place GPU workers on a private subnet; the public web app should not hold GPU credentials. Strip PII before prompts leave your app, validate structured JSON outputs in PHP after generation, and log hashes rather than full prompt text. Apply rate limits at the reverse proxy and per-customer quotas in your application layer. That separation simplified audits and firewall rules on a legal-tech portal where document summarization ran behind a queue with per-firm rate limits.

VRAM holds model weights, KV blocks, and activation buffers in one pool—OOM kills the worker hard with no graceful recovery. Common triggers include max-model-len set too high for RAG workloads, gpu-memory-utilization pinned at 1.0 leaving no headroom for CUDA context spikes, or max-num-seqs raised until KV blocks exhaust available memory. Fix by lowering max-model-len to match real prompts, setting gpu-memory-utilization around 0.90, enabling AWQ or GPTQ quantization to shrink weight footprint, or using tensor-parallel-size to spread a large model across multiple GPUs. Use a process supervisor or container restart policy so OOM events recover automatically while you tune block allocation.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: