What is LLM infrastructure?
LLM infrastructure is the collection of hardware, software, networking, storage, and operational systems required to run large language models reliably. It includes GPU compute, model weights, inference runtimes, API serving, request scheduling, monitoring, security, and deployment processes.
Connecting an application to a hosted AI API is one way to build an AI product. Operating the model-serving layer yourself is a different engineering challenge. It gives an organisation more control over deployment, data flow, model choice, and infrastructure configuration, but also makes it responsible for capacity, reliability, security, and cost.
1. Start with workload requirements, not GPU shopping
Before choosing hardware, understand the workload.
Important questions include:
- Which model and parameter size are required?
- What context length must be supported?
- How many concurrent users or requests are expected?
- What are the latency and throughput targets?
- Is the workload text, image, audio, or multimodal?
- Can requests be queued, or must they be served in real time?
- What data residency, privacy, or network constraints apply?
A model that works for a single developer may fail under concurrent production traffic. The total memory requirement depends on more than model weights: runtime overhead, context/KV cache, batching, and other loaded components also consume memory.
2. Understand GPUs, CUDA and VRAM
GPUs accelerate the matrix operations used by neural-network inference. NVIDIA GPUs commonly use CUDA, a parallel computing platform and programming model that allows software to execute workloads on compatible NVIDIA hardware.
For inference, GPU memory (VRAM) is often a key constraint. Model weights must be loaded, and additional memory is needed for runtime buffers and the key-value (KV) cache used to retain attention context.
Lower-precision formats such as FP16 or quantised weights can reduce memory requirements, often at a trade-off in numerical precision or output quality. The best choice depends on model support, hardware, and evaluation results. Do not assume that a model's parameter count alone tells you whether it will fit.
GPU placement also matters. Separating two workloads across devices can reduce memory contention, but does not automatically improve total throughput. Measure utilisation, memory headroom, latency, and contention under realistic load.
3. Choose an inference and serving runtime
An inference runtime loads model weights and executes generation. A serving layer exposes that capability to applications through an API, manages requests, and handles operational concerns.
Common options serve different needs:
- Ollama offers a straightforward way to run and expose local models. It is useful for development, experimentation, and some deployments. Its concurrency and queue behaviour must be configured with available memory in mind.
- vLLM is designed for high-throughput LLM serving and includes techniques such as PagedAttention and continuous batching to improve memory management and request scheduling.
- Other runtimes and vendor stacks may be appropriate depending on hardware, model architecture, deployment environment, and performance targets.
Do not select a runtime based on popularity alone. Benchmark the actual model, prompt lengths, concurrency, and hardware you intend to operate.
4. Design a stable model-serving API
Keep the application layer separate from the inference layer.
A common architecture looks like this:
Web / Mobile Client
|
Application API
(authentication, business rules, rate limits)
|
Model Gateway / Provider Interface
|
Queue or Scheduler
|
Inference Worker(s)
(GPU + model runtime)
|
Model output
|
Validation, logging, responseThe application API should not need to know every detail of the GPU runtime. Define stable provider interfaces and consistent request/response contracts so a team can change model providers without rewriting the entire product.
A serving layer should consider:
- Authentication between services.
- Request validation and context limits.
- Timeouts and cancellation.
- Queue limits and overload responses.
- Retry policies that do not duplicate side effects.
- Model readiness and health checks.
- Structured errors for unavailable models and GPU memory failures.
- Streaming responses where the user experience requires them.
A health endpoint should distinguish a running process from a model that is actually loaded and ready to serve requests.
5. Deploying self-hosted models with Ollama
Ollama can make local model operation accessible through a simple HTTP interface. For production, teams still need to understand model loading, concurrency, queue limits, storage, network exposure, authentication, and monitoring.
Ollama's documentation describes configuration for maximum loaded models, parallel requests, and queue capacity. Parallel requests can increase memory requirements because each request needs context/KV-cache resources. If available memory is insufficient, requests may queue or fail.
Do not expose an inference port publicly without a security design. Place the service behind an authenticated gateway or private network, restrict access, manage secrets securely, and monitor resource consumption. Test overload behaviour instead of assuming the service will scale automatically.
6. Monitoring and operating LLM inference
Traditional infrastructure monitoring is necessary but not sufficient. Track both system and model-serving signals.
Infrastructure metrics
- GPU utilisation and VRAM usage.
- CPU, RAM, disk, and network utilisation.
- Worker availability and restart count.
- Queue depth and rejected requests.
- Container health and deployment status.
Inference metrics
- Time to first token.
- Tokens generated per second.
- End-to-end latency.
- Input and output token counts.
- Throughput and concurrency.
- Model load time and cold-start frequency.
- Timeout, cancellation, and error rates.
Quality and cost metrics
- Task success and evaluation scores.
- Hallucination or unsupported-answer rate where measurable.
- Retrieval relevance for RAG systems.
- Cost per successful task.
- Human escalation and correction rate.
Avoid logging raw prompts and completions indiscriminately. They may contain personal, confidential, or regulated information. Define data minimisation, redaction, retention, and access controls.
7. Production reliability and security
A reliable model-serving system needs resource limits, graceful shutdown, health checks, deployment rollback, capacity planning, and failure isolation. Use queues and backpressure to protect the GPU workers from bursts. Apply request limits and budgets to prevent runaway usage.
For agentic applications, secure the tools and permissions separately from the model server. A model endpoint should not imply permission to access business systems. OWASP's GenAI guidance highlights prompt injection, sensitive information disclosure, and excessive agency as risks that require application-level controls.
8. Self-hosted inference or hosted APIs?
| Factor | Hosted model API | Self-hosted inference |
|---|---|---|
| Initial setup | Usually faster | More infrastructure work |
| Hardware operations | Provider-managed | Your responsibility |
| Model choice | Provider catalogue and terms | Greater deployment control |
| Scaling | Provider capacity and limits | You plan and operate capacity |
| Data flow | Data sent to provider under contract | Can keep inference within controlled infrastructure |
| Cost model | Usage-based or contracted | Hardware, hosting, operations, and utilisation |
| Best fit | Fast delivery and variable workloads | Specific control, predictable workloads, or deployment constraints |
Self-hosting is not automatically cheaper or more private. The result depends on utilisation, hardware amortisation, operations, model quality, data handling, and provider terms. Hybrid architectures are often sensible: use hosted models for some workloads and self-hosted models for others.
The engineering principle
Production LLM infrastructure is not just about getting a model to generate text. It is about serving the right model, on suitable hardware, under realistic concurrency, with predictable latency, bounded cost, secure access, and measurable quality.
Baseline44 explores this layer as part of its AI engineering work: model integration, self-hosted inference, GPU-aware deployment, agentic workflows, and operational monitoring. The right architecture begins with workload requirements and evidence from benchmarks, not assumptions about a particular GPU or framework.
Planning an AI system beyond API integration? Explore Baseline44 AI solutions or contact our engineering team.
Sources and further reading
- Ollama FAQ and concurrency configuration
- vLLM documentation
- NVIDIA CUDA documentation
- OWASP GenAI Security Project
- Google Cloud generative AI architecture guidance
Need this for your business?
Book a free consultation and we'll map it to your situation.
Book a consultationI'm Alex Njoroge, an AI and software engineer at Baseline44. I build grounded AI systems, retrieval pipelines and production software for organisations in Kenya, and I write about the engineering decisions behind projects like Sheria Bot.
