DEV Community

shashank ms
shashank ms

Posted on

Deploying LLM on a Server: A Comprehensive Guide

Deploying a large language model on your own server is one of the most asked questions in AI infrastructure forums, yet few guides cover the full stack from hardware selection to API exposure. Whether you are building a private chat interface, embedding an agent into an on-premise product, or simply avoiding the latency of public clouds, self-hosting gives you control over data residency, custom fine-tuning, and inference scheduling. This article walks through the complete lifecycle: choosing hardware, selecting an inference engine, containerizing the service, and exposing it to client applications. We will also look at when managed inference platforms like Oxlo.ai remove the operational burden entirely.

Hardware Selection and Sizing

Before downloading any weights, determine the compute footprint. A model's parameter count, quantization level, and batch size dictate GPU memory and CPU RAM requirements.

For unquantized inference, use this rule of thumb: every one billion parameters needs roughly 2 GB of VRAM at FP16, or 4 GB at FP32. A 70 B model such as Llama 3.3 70B therefore needs about 140 GB of VRAM at FP16, which means two NVIDIA A100 80 GB GPUs or four A10G 24 GB GPUs with tensor parallelism. If you quantize to 4-bit (AWQ or GPTQ), the same 70 B model compresses to roughly 40 GB, fitting on a single A100 40 GB or an RTX 4090 with some overhead for the KV cache.

For CPU-only deployments, llama.cpp enables inference on standard server hardware. Expect throughput to drop by an order of magnitude compared to GPU inference, but for low-traffic internal tools this is acceptable. A 32 B model quantized to Q4_K_M needs approximately 20 GB of system RAM and runs comfortably on a server with 64 GB RAM and modern AVX-512 support.

Network bandwidth matters if you serve multiple concurrent users. A 1 Gbps NIC is sufficient for a single model instance, but if you shard a large model across multiple nodes, invest in 10 Gbps or InfiniBand to keep inter-GPU communication from bottlenecking generation speed.

Inference Engines and Quantization

The engine you choose determines throughput, batching behavior, and API compatibility.

vLLM is the current standard for high-throughput GPU serving. It implements PagedAttention to minimize KV cache waste and supports continuous batching, so new requests can join an ongoing batch without waiting for the current one to finish. vLLM exposes an OpenAI-compatible HTTP server out of the box.

llama.cpp is the pragmatic choice for CPU inference or heterogeneous environments. It supports GGUF quantization formats and runs on ARM, x86, and even WebAssembly. Its HTTP server is lightweight but lacks advanced scheduling.

TensorRT-LLM (NVIDIA) and TGI (Hugging Face) are alternatives when you need maximum optimization for specific hardware. TensorRT-LLM compiles models into optimized engines for Ampere and Hopper GPUs, while TGI simplifies deployment with built-in token streaming and safetensors loading.

Quantization is not just about fitting a model into memory. It reduces memory bandwidth pressure, which is often the actual bottleneck during autoregressive decoding. Test your target model at Q4_K_M or FP8 before assuming you need full FP16. If you use vLLM, you can load an AWQ or GPTQ model directly:

python -m vllm.entrypoints.openai.api_server \
  --model TheBloke/Llama-3.3-70B-AWQ \
  --quantization awq \
  --tensor-parallel-size 2 \
  --port 8000
Enter fullscreen mode Exit fullscreen mode

Containerization and Orchestration

Running inference on bare metal works for experiments, but production deployments need reproducible environments. Package your inference server with Docker, then orchestrate with Kubernetes or Docker Compose.

A minimal Dockerfile for vLLM looks like this:

FROM vllm/vllm-openai:latest

ENV MODEL_NAME="meta-llama/Llama-3.3-70B-Instruct"
ENV TP_SIZE=2

EXPOSE 8000

CMD python -m vllm.entrypoints.openai.api_server \
    --model $MODEL_NAME \
    --tensor-parallel-size $TP_SIZE \
    --port 8000 \
    --host 0.0.0.0
Enter fullscreen mode Exit fullscreen mode

Build and run:

docker build -t llm-server .
docker run --gpus all -p 8000:8000 llm-server
Enter fullscreen mode Exit fullscreen mode

For Kubernetes, use a StatefulSet with node affinity to pin the pod to GPU nodes. Mount model weights on a ReadWriteMany volume or cache them with a container image layer to avoid pulling multi-gigabyte files on every restart. Set resource limits explicitly:

resources:
  limits:
    nvidia.com/gpu: "2"
    memory: "128Gi"
Enter fullscreen mode Exit fullscreen mode

Health checks should probe the /health endpoint provided by vLLM or your chosen engine, not just whether the container is running.

API Gateway and Load Balancing

A single model instance is rarely enough for production traffic. You need request routing, rate limiting, and failover.

Nginx or Envoy can proxy to multiple vLLM replicas, but they do not understand request length or GPU queue depth. For LLM-aware routing, use LiteLLM Proxy or a custom scheduler. LiteLLM accepts OpenAI-formatted requests and distributes them across backend workers based on token capacity, error rates, or model aliases.

Rate limiting should be based on requests per minute and estimated tokens per minute. Unlike traditional REST APIs, LLM latency varies from 100 ms to 30 seconds depending on output length, so circuit breakers must tolerate long tails without killing valid connections.

If you expose the service externally, terminate TLS at the gateway and authenticate with API keys. vLLM's built-in server supports --api-key, but rotating keys and auditing usage typically require a separate layer.

Monitoring, Logging, and Autoscaling

Track three golden signals: time to first token (TTFT), time per output token (TPOT), and queue depth. Prometheus metrics are available in vLLM via --enable-metrics. Export these to Grafana and alert when TPOT exceeds your SLA, usually 50-100 ms per token for interactive use.

Log prompts and completions for debugging, but hash or truncate sensitive fields to comply with data policies. Store logs in a centralized system such as Loki or Elasticsearch.

Autoscaling GPU workloads is harder than scaling stateless containers. Cold-start times for large models can exceed five minutes, so reactive scaling based on request count alone causes timeouts. Use predictive scaling based on time-of-day patterns, or maintain a warm pool of standby instances. Cluster autoscalers with GPU node pools help, but be aware that cloud GPU availability varies by region.

When Self-Hosting Makes Sense, and When It Does Not

Self-hosting is justified when you have strict data residency requirements, need to run fine-tuned weights that cannot leave your network, or operate at a scale where cloud markups exceed engineering salaries. It also makes sense for research environments where you want to modify the inference engine itself.

However, the operational overhead is substantial. You are responsible for driver updates, CUDA compatibility, security patches, quantization tuning, and capacity planning. For teams that would rather focus on application logic than on-call rotations for GPU nodes, a managed inference platform is the pragmatic alternative.

Oxlo.ai is a developer-first AI inference platform built on request-based pricing: one flat cost per API request regardless of prompt length. Unlike token-based providers such as Together AI, Fireworks AI, OpenRouter, Replicate, or Anyscale, Oxlo.ai does not scale cost with input length, which makes it significantly cheaper for long-context and agentic workloads. The platform offers 45+ open-source and proprietary models, including Llama 3.3 70B, DeepSeek R1 671B MoE, Qwen 3 32B, and Kimi K2.6, with full OpenAI SDK compatibility and no cold starts on popular models. If your workload involves large context windows, multi-turn agents, or unpredictable token volumes, Oxlo.ai removes the infrastructure burden while keeping costs predictable. You can explore pricing at https://oxlo.ai/pricing.

Conclusion

Deploying an LLM on a server is a multi-step process that spans hardware sizing, engine selection, container packaging, and production-grade routing. Start with a quantized model on a single GPU, wrap it in a container with health checks, and place it behind an API gateway that understands LLM traffic patterns. Monitor TTFT and TPOT aggressively, and be realistic about the maintenance cost of self-hosted GPU clusters. For teams that need reliable, scalable inference without building an infrastructure team, managed platforms like Oxlo.ai provide an OpenAI-compatible API with flat per-request pricing that favors long-context and agentic use cases. Choose the path that matches your operational capacity and latency requirements.

Top comments (0)