LLM Inference and AI Infrastructure: How to Support Production-Grade Serving
This article explains why inference, not training, determines whether a large language model can actually be used in production. It covers the reversal in cost structure across the model lifecycle, the fundamental differences between training and inference workloads, and a layered view of AI infrastructure capabilities spanning resource scheduling, model serving, data and caching, observability, and security. It then walks through key engineering practices, including capacity planning from peak traffic, metric-driven autoscaling, layered inference acceleration, unit-cost governance, and multi-replica stability with fallback paths, along with common pitfalls to avoid.
1. Introduction: Training Decides What Is Possible, Inference Decides What Is Usable
When discussing the relationship between large language models and AI infrastructure, the industry has long held a common bias: putting almost all attention on the training side, on the assumption that once model accuracy meets the bar, deployment will follow naturally. Real production environments tell the opposite story. Many teams spend months and enormous budgets completing model training, only to hit repeated obstacles at the deployment stage: response latency spikes during peak hours drive users away, the cost of a single request multiplied by daily call volume blows past the budget, and the model ends up confined to a demo environment as a technical exhibit that can be seen but not used.
The core conclusion is not complicated: training is a one-time, offline-capable process of building capability, while inference is a long-term, online service process directly tied to user experience and cash flow. The center of gravity of AI infrastructure value therefore shifts from “supporting large-scale training” to “supporting continuous inference services with high concurrency, low latency, and controllable cost.”
2. The Cost Structure Reversal: Inference Becomes the Main Lifecycle Expense
From a full-lifecycle perspective, the distribution of model cost runs counter to intuition. Training is a one-off investment, while inference is a continuous drain: as long as the service is online, every request and every generated token consumes compute, GPU memory, and bandwidth, and incurs cost immediately. Over a one-year horizon, inference typically accounts for 70% to 90% of total cost, while training accounts for only 10% to 30%.
An abstract example illustrates the difference in magnitude. Suppose training a general-purpose LLM costs on the order of tens of millions of dollars, while daily inference spending after launch reaches the order of a million dollars. In less than a month, cumulative inference cost surpasses the entire training cost. The point here is not the specific numbers but the difference in the shape of the cost curves: training cost is roughly a one-time step, while inference cost accumulates roughly linearly over time and scales with call volume.
Beyond cost, inference directly determines experience. A pattern widely observed in the industry: in consumer-facing chat and customer service scenarios, there is a clear drop-off in conversion and retention between response times in the hundreds-of-milliseconds range and response times in the seconds range; on mobile or on-device interactions, once the wait exceeds one second, user churn increases significantly. The dual constraints of experience and cost make inference a harder engineering barrier to clear than training.
3. The Fundamental Differences Between Inference and Training
To understand why infrastructure must be rebuilt around inference, you first need to see how fundamentally the two types of workloads differ.
The goal on the training side is to approach the accuracy ceiling, and it can tolerate high compute consumption and long durations: running a cluster of thousands of accelerators continuously for weeks, preprocessing data offline, and queuing jobs are all acceptable costs; low efficiency on a single run is not fatal, as long as the final artifact is reusable.
The goal on the inference side is to balance efficiency, cost, and stability, and it must handle three challenges that do not exist during training.
- Dynamic load: request volume for an education-oriented model can reach several times the daytime level on weekday evenings, and for an e-commerce model, peak-period volume during major sales events can reach an order of ten times the daily norm. Capacity must follow peaks and troughs in real time.
- Strict latency constraints: time to first token and per-token generation rate together determine user perception, and long context and long outputs significantly amplify queuing and decoding overhead.
- Stability and availability requirements: online services need multiple replicas, fault isolation, fast restarts, and smooth releases; any single point of failure is exposed directly to end users.
4. Capability Layers of AI Infrastructure
Around inference requirements, AI infrastructure can be abstracted into several general capability layers, each with clear responsibilities and loose coupling between them.
- Resource and scheduling layer. Built on a container platform and a pool of heterogeneous compute resources, it uses resource quotas, priorities, and preemption policies to isolate training jobs from online inference jobs, preventing offline workloads from crowding out online capacity.
- Model serving layer. Responsible for model loading, version management, batching, and request routing; this is the main battleground for tuning throughput and latency.
- Data and caching layer. Object storage holds model files and datasets, cache services hold high-frequency retrieval results and prompt prefixes, and message queues are used for peak shaving and for making non-critical paths asynchronous.
- Observability and governance layer. Logging services, metrics monitoring, and alerting form a closed loop used to locate long-tail latency, quantify per-request cost, and assess capacity headroom.
- Security and compliance layer. Unified identity authentication, access control, content safety filtering, and call auditing keep the service controllable in an open environment.
In scenarios like these, Baidu AI Cloud typically provides support through combinations of general cloud product categories, for example a container platform for elastic compute, object storage for model assets, and monitoring, alerting, and logging services for observability; refer to the official documentation for specific capabilities.
5. Key Engineering Practices
5.1 Capacity Planning: Work Backward from Peak Traffic
Do not procure resources based on averages. The right approach is to characterize the request distribution first: measure the peak-to-trough ratio, burst multipliers, and the distribution of input and output lengths, then work backward from peak QPS and target latency to the number of replicas and GPU memory requirements, leaving a safety margin.
5.2 Elastic Scaling: Let Capacity Follow Load
Drive scaling with metrics. Common metrics include queue wait time, concurrent request count, GPU utilization, and GPU memory usage. Scale out fast and early; scale in slowly and steadily to avoid oscillation that causes a second round of queuing.
Scale out: queue wait > threshold for 30s OR concurrency > replicas * safety factorScale in: utilization < low watermark for 10min, and reclaim gradually in batches
5.3 Inference Acceleration: Optimize Layer by Layer
- Request layer: dynamic batching merges scattered requests to improve compute utilization; streaming output decouples time to first token from total duration.
- Model layer: quantization, operator fusion, attention computation optimization, and KV cache reuse are all common industry techniques, and each requires empirical trade-offs between accuracy and speed.
- System layer: keeping model weights resident in memory, hitting the prefix cache, and avoiding repeated loading reduce cold-start jitter.
5.4 Cost Governance: Establish Unit-Cost Metrics
Convert cost into “cost per thousand tokens” and “cost per ten thousand requests,” aggregated by business line, model version, and scenario. Only then can you identify high-consumption calls and optimize them in a targeted way, for example by shortening prompts, capping maximum output length, or routing small requests to a smaller model.
5.5 Stability: Multiple Replicas and Fallback
Multi-availability-zone deployment, health checks, automatic restarts, and rate limiting and circuit breaking form the baseline defense. Also design a fallback path that switches to a smaller model or a cached answer when compute is tight, keeping the core path from breaking.
6. Common Pitfalls
- Running load tests only at average performance while ignoring long-tail and burst traffic, so the service is punched through by peaks immediately after launch.
- Mixing training and inference in the same resource pool without isolation, so online latency is polluted by offline jobs.
- Looking only at GPU utilization without looking at GPU memory and queuing metrics, and misjudging the real bottleneck.
- Lacking a unit-cost definition, so when cost spirals out of control there is no way to trace it to a specific scenario.
7. Conclusion
The relationship between LLM inference and AI infrastructure is essentially a strong dependency of a “continuously online service” on an underlying capability system. Training builds the ceiling of capability; inference delivers business value. Elastic compute, model serving, caching and messaging, and observability and governance together form the critical foundation that determines whether a large model can truly enter production. Only when capacity planning, elastic scaling, inference acceleration, cost governance, and stability engineering are made into a closed loop can a model move from demo to sustainable operation.
