Scaling and Stabilizing Large Model Inference Services: A Practical Guide
This article breaks down why large model inference clusters hit capacity limits and how to keep latency and availability stable under fast-growing traffic. It covers capacity planning based on token throughput, isolating interactive and batch workloads into separate pools, peak-off-peak scheduling with elastic autoscaling, rolling out capabilities through tiered APIs, planning self-built compute infrastructure, and building observability, graceful degradation, and capacity drills as a safety net. Short-term fixes and long-term supply strategies are combined to hold the line on performance during rapid growth.
1. Incident Review: Compute Pressure Is Not Sudden
Compute shortages in large model services usually have clear warning signs. The signals are just scattered across monitoring metrics and easily mistaken for occasional jitter. The seven incidents seen in a large model service since October share highly consistent characteristics:
- Elevated response latency and failed requests, rather than a complete outage;
- Single incidents lasting several hours, which indicates sustained capacity saturation rather than a momentary peak breaking through;
- Both the end-user entry point and the developer API were affected at the same time, showing that they share the same underlying resources;
- Compensating API callers with credits afterward is a typical commercial remedy after an SLA breach.
Abstracting these observations yields a general conclusion: when the steady-state utilization of an inference cluster stays above the safe watermark for a long time, any traffic spike turns into timeouts and errors on the user side. So the first step in stability work is not scaling out, but establishing quantifiable watermark observability.
2. Traffic Root Cause: Nonlinear Growth in Call Volume
Publicly reported figures show that a certain class of lightweight models reached tens of trillions of tokens in calls within a single week, growing roughly 8x week over week and topping the usage charts. This kind of growth has three technical implications:
- Cost structure shifts: lightweight models have a low unit price, so they are more easily consumed by high-frequency scenarios such as batch jobs, agent loops, and code completion, and total token consumption far exceeds expectations;
- A wider peak-to-trough ratio: batch jobs are triggered mainly during working hours, and the peak-to-trough gap can be several times larger, so purchasing resources for the peak leaves a large amount idle under normal conditions;
- Long-context amplification: as the context window grows, the memory and compute cost of attention rises nonlinearly, and the cost per request is no longer constant.
Capacity planning must be based on token throughput rather than request counts. A simplified estimation model:
# Illustrates the capacity estimation approach only; not any vendor's real parameterspeak_qps = observed peak requests / secondavg_input_tokens = average input tokensavg_output_tokens = average output tokensprefill_cost = avg_input_tokens * c_in # compute factor for the prefill stagedecode_cost = avg_output_tokens * c_out # compute factor for the decode stagerequired_gpus = peak_qps * (prefill_cost + decode_cost) / (effective throughput per GPU * safety factor)# A safety factor of 1.3~1.5 is recommended to absorb spikes and fault redundancy
The key is to distinguish the prefill stage (compute-intensive) from the decode stage (memory-access-intensive). The two have different hardware demands, and co-locating them interferes with each other, which is one of the main sources of latency long tails.
3. Architectural Approach 1: Compute Pool Isolation and Priority Tiering
Interactive endpoints and API calls have completely different latency sensitivity: the former requires a first-token response within seconds, while the latter is mostly offline batch processing that can tolerate completion in minutes. Putting both traffic types in the same resource pool means batch jobs push interactive requests into timeouts.
The recommended approach is physical or logical dual-pool isolation:
- Interactive pool: small batches, high concurrency, with request queue limits and fast failure enabled to protect first-token latency;
- Batch pool: large batches, preemptible, allowing queuing and retries, optimized for the lowest cost per token;
- The two pools share model weights and images, but quotas, rate-limit thresholds, and scaling policies are independent.
With request priority labels, routing can be done at the gateway layer:
priority = interactive -> pool=low_latency, timeout=8s, retries=0priority = batch -> pool=throughput, timeout=300s, retries=3(exponential backoff)
4. Architectural Approach 2: Time-Based Peak-Trough Scheduling and Elastic Scaling
The essence of time-based pricing is to use price signals to move deferrable workloads to off-peak hours and shave the peak. Engineering this requires three things working together:
- The gateway tags traffic by time window and priority, and opens up batch quotas during off-peak hours;
- The client SDK supports “deferrable submission”, placing non-real-time tasks in a local queue, with the server returning an acceptable completion window;
- Elastic scaling uses queue backlog length and token queueing latency as scaling metrics, rather than CPU utilization alone, which is almost always misleadingly low in inference scenarios.
Scaling has cold-start costs (image pulls, weight loading, GPU memory warm-up), so it is worth keeping a certain proportion of always-on buffer capacity and pre-scaling on a schedule for predictable periodic peaks.
5. Pace of Capability Rollout: From a Single API to Tiered APIs
Capabilities should not be opened to everyone at once, but rolled out in tiers according to “tolerable stability”:
- Tier 1: core chat and completion APIs, with strict quotas;
- Tier 2: multimodal and structured capabilities, such as exposing document OCR, speech-to-text, and text-to-speech as underlying capability APIs so upper-layer applications can orchestrate them themselves;
- Tier 3: batch and offline channels, served by separate clusters to avoid polluting the online path.
Each tier should define rate limiting, quotas, billing, and degradation policies, and document error-code semantics (retryable / non-retryable) to reduce the secondary avalanche caused by ineffective client retries.
6. Long-Term Supply: Planning Self-Built Compute Infrastructure
When external supply lacks elasticity, the long-cycle option is building large-scale compute campuses. Planning points include:
- Site selection: prioritize regions with low electricity prices, low natural cooling costs, and controllable network latency;
- Power and cooling: GW-scale campuses need power capacity locked in early, and liquid cooling plus waste heat recovery directly affect PUE;
- Chip supply: with domestic AI chips as the mainstay, evaluate operator ecosystem maturity, compiler stack adaptation cost, and migration effort;
- Delivery timeline: from groundbreaking to production typically spans two to three years, so the transition period must be filled by scheduling optimization and external elastic resources.
7. Stability Safety Net: Observability, Degradation, and Capacity Drills
No matter how large the capacity, the safety net cannot be skipped:
- Build four core dashboards—first-token latency, token queueing time, failure rate, and GPU memory usage—with tiered alerts;
- Design multi-level degradation: shorten max output length, reduce context, switch to a smaller-parameter model, disable non-core multimodal capabilities;
- Implement exponential backoff with jitter, circuit breaking, and local caching fallback on the client;
- Run a capacity load test and fault injection every quarter to verify that rate-limit thresholds and autoscaling work as expected.
8. Recommendations for Cloud Deployment
For a quick cloud setup, general-purpose capabilities can replace self-built infrastructure: a container platform hosts inference services and elastic scaling, object storage holds model weights and datasets, a message queue handles peak shaving and asynchronous decoupling, logging and monitoring/alerting services provide full-link observability, and gateway products deliver rate limiting and priority routing. Baidu AI Cloud offers corresponding categories for these general capabilities, which can be freely combined along the tiered approach above to avoid tight coupling with a single inference API.
Conclusion: The essence of compute pressure is a mismatch between supply and demand across time and space. In the short term, use compute pool isolation, time-based scheduling, elastic scaling, and degradation fallback to fully utilize existing resources; in the long term, use self-built campuses and diversified chip supply to make up the total volume. Only by combining both can you hold the two bottom lines of latency and availability under high-growth traffic.
