Compute Infrastructure and Cost Governance for Scaling Large Language Models
This article covers the compute demands of training and inference for large language models. It explains how to calculate unit request cost, estimate inference capacity with Little's Law, and manage infrastructure risks as model scale grows.
1. Background: Resource Pressure from Larger Models
Over the past few years, the parameter counts, training data volumes, and online inference request volumes of large language models have kept growing. Training organizes large numbers of accelerator cards into clusters that run continuously for days or even weeks. Inference must handle high-concurrency, low-latency online requests. The two workloads have different resource profiles, but both push infrastructure costs to high levels.
Investor attention on companies in this space also reflects one fact: compute scale has become a key factor in how fast models iterate and how available services are. For developers and enterprise teams, the question has shifted from “Can the model run?” to “Can the model run stably over the long term at a controllable cost?”
2. Three Core Dimensions of Compute Demand
1. Training: Throughput and Communication Efficiency
Training jobs typically compute in synchronized batches. Gradient synchronization bandwidth across cards, data loading speed, and checkpoint write efficiency all directly affect effective compute utilization. Even with ample accelerator cards, if communication becomes a bottleneck, much of the compute time is wasted waiting.
2. Inference: Latency and Elasticity
Online inference request volume often has clear peaks and troughs. Concurrency during daytime peak hours can be several times higher than at night. Systems need batching, concurrency limits, and autoscaling to balance latency and cost. Cold start time is also a design factor. If model loading takes too long, it directly slows down scaling response.
3. Data and Storage: Stability and Access Speed
Sample cleaning, vector index construction, and retrieval-augmented generation all depend on a stable storage layer. Object storage holds raw data and model files, while a high-speed cache layer serves hot data reads. If the storage layer shows latency jitter, the tail latency of inference services rises accordingly.
The table below summarizes the typical focus areas for each workload:
| Workload | Key Metrics | Main Risks | Common Mitigations |
|---|---|---|---|
| Training | Effective compute utilization, iteration time | Communication bottlenecks, job interruptions | Topology-aware scheduling, regular checkpointing |
| Inference | P95/P99 latency, request success rate | Peak overload, slow cold starts | Batching, elastic scaling, warm instances |
| Data and storage | Read throughput, cache hit rate | Access jitter, insufficient capacity | Tiered storage, hot-data caching |
3. Unit Cost Accounting
Many teams track only monthly resource bills and cannot answer “How much did one request actually cost?” Building a unit cost model is a prerequisite for cost reduction decisions.
1. Cost Components
Unit request cost can be estimated as follows:
Unit request cost = (accelerator cost per unit time × resource occupancy time + storage and network fees + amortized operations labor) ÷ number of valid requests
Valid requests count only successfully returned requests. Failed and timed-out requests are excluded. If failed requests are included in the denominator, the cost is underestimated, and the team cannot see the true cost of service quality problems.
2. Effective Utilization
The share of resource occupancy time actually spent on computation is called effective utilization:
Effective utilization = actual compute time ÷ total resource occupancy time
Low utilization usually has three causes: idle instances, batch sizes that are too small, and load that is not evenly distributed after scaling out. Investigating these three areas often yields larger cost improvements than adjusting unit prices.
3. Worked Example
The following figures are hypothetical and only illustrate the calculation. Suppose an inference service costs 100 CNY per hour in resources and completes 5,000 successful requests per hour. Storage and labor costs are excluded. The cost per request is about:
100 ÷ 5,000 = 0.02 CNY
If effective utilization is only 50%, the effective cost must be recalculated based on occupancy time. Teams should display utilization and unit cost on the same monitoring dashboard and track them continuously.
4. Capacity Estimation
The goal of capacity estimation is to determine how many inference instances are needed while meeting latency requirements. Little’s Law from queueing theory offers a concise framework: the average number of concurrent requests in a system equals the arrival rate multiplied by the average time each request spends in the system.
1. Estimation Formula
Concurrency L = peak request rate λ × average processing time W
After calculating concurrency, combine it with the batching capacity of a single instance and the target utilization to derive the instance count.
2. Sample Code
The pseudocode below shows the estimation logic. Specific parameters should be determined from load test results.
function estimate_instances(peak_rps, avg_latency_s, batch_size, target_util):# Little's Law: concurrency = arrival rate × average processing timeconcurrency = peak_rps * avg_latency_s# Effective concurrency per instance per round = batch size × target utilizationeffective_per_instance = batch_size * target_utilinstances = ceil(concurrency / effective_per_instance)# Keep a safety margin for traffic bursts and instance failuresreturn ceil(instances * 1.2)
The 1.2x margin in the code is only a common starting value. Teams should adjust this factor based on their tolerance for failures, recovery time, and traffic fluctuation.
3. Capacity Planning Process
- Establish a baseline: record the current peak request rate, average processing time, and resource usage.
- Run load tests: measure the latency distribution at different concurrency levels in a configuration close to production.
- Calculate the configuration: apply the estimation formula to get an initial instance count.
- Reserve headroom: keep redundancy for traffic bursts and failover.
- Review regularly: recalibrate the baseline every quarter or after each model version update.
5. Engineering Practices
1. Resource Isolation and Scheduling
Deploy training jobs and online inference jobs in separate resource pools. Training jobs can usually be queued or interrupted and resumed. Inference jobs require stable response times. When the two share a pool, a large training job can take resources from inference and cause online latency to spike.
2. Elastic Scaling Policies
Scaling triggers should not rely only on CPU or accelerator memory usage. Include request queue length and latency percentiles as well. Queue backlog is an earlier overload signal than resource utilization. New instances must finish model loading and warm-up in advance, so they are ready before traffic peaks arrive.
3. Monitoring and Alerting
Collect at least the following metrics:
- Accelerator utilization and memory usage
- Request rate, success rate, and timeout rate
- Latency percentiles (P50, P95, P99)
- Actual distribution of batch sizes
- Cache hit rate and storage read latency
Set alert thresholds based on historical data, and define alert severity levels. Short spikes in a single metric usually do not need manual intervention. Latency that stays above threshold for several minutes does need prompt action.
4. Caching and Computation Reuse
Identical or highly similar requests can reuse cached results. For inputs with a fixed prefix, intermediate computation states can be cached to reduce repeated computation. Caching policies must account for data freshness and privacy requirements. Outdated content and sensitive information should not be kept for long periods.
5. Trade-offs of Cost Reduction Methods
Common cost reduction methods include model quantization, knowledge distillation, and request routing. Quantization reduces memory usage but may cause accuracy loss. Distillation requires additional training cost. Routing sends simple requests to smaller models and complex requests to larger ones. Each method should be validated through offline evaluation and canary releases. Cost figures alone are not enough.
6. Risks and Mitigations
The main risks to compute infrastructure include:
- Supply fluctuations: accelerator procurement lead times are long, so rapid short-term expansion is difficult. Mitigate this by forecasting capacity needs early and staying in close contact with hardware suppliers.
- Price changes: resource unit prices may shift with the market. Mitigate this by setting up cost alerts and evaluating reserved or committed use plans for long-running workloads.
- Single points of failure: if a single availability zone or resource pool fails, the service goes down. Mitigate this by deploying across multiple availability zones and designing degradation paths for critical services.
- Model version changes: a new version may have significantly different resource requirements. Mitigate this by load testing before release and comparing unit cost between old and new versions.
7. Recommendations
- Start by monitoring unit cost and utilization to establish the actual cost structure.
- Divide resources into pools by workload type to prevent training and inference from interfering with each other.
- Base capacity planning on Little’s Law and load test data rather than rough estimates.
- Include cost reduction methods in the canary release process, and use quality metrics to constrain optimization.
- Review the relationship between cost and service quality every quarter, and keep planning parameters calibrated.
Competition in large model applications is extending from model capability to infrastructure efficiency. The sooner teams build a quantifiable cost and capacity system, the better they can balance model iteration against service stability.
