LLM Capacity Planning and GPU Scheduling: A Practical Guide to Handling Traffic Spikes
This guide explains why inference capacity runs short during traffic spikes and how to fix it with engineering practices. It covers building a repeatable capacity model, request tiering and admission control, graceful degradation routing, elastic scaling and resource pooling, observability metrics, release checklists, and user communication. The goal is to replace guesswork with measurable, controllable, and cost-predictable LLM inference operations.
1. The Root Cause: Why Inference Capacity Runs Short
Within two weeks of a major release, a large model assistant experienced noticeable service instability during peak hours. The UI displayed a capacity warning and switched to a faster response mode; in user feedback, the official team even suggested trying other options as a temporary workaround. Scenarios like this are common in inference services. On the surface it looks like “insufficient resources,” but the real issue is that capacity planning, traffic patterns, and cost constraints are not aligned.
First, clarify the concepts: training capacity focuses on throughput and cluster utilization, while inference capacity focuses on controllable tail latency. The resource cost of a single request is not determined by “model size” alone, but by several variables:
- Total input and output tokens, especially the attention computation and memory growth caused by long contexts;
- Concurrent request count and batching strategy: larger batches increase throughput but also increase queuing and tail latency;
- The token-by-token nature of the decoding phase, where memory bandwidth often becomes the bottleneck before compute does;
- Multi-agent parallelism and tool calls, which can amplify a single user request into dozens of model calls.
Therefore, once a new version supporting large-scale parallel subtasks goes live, the cost per request may be several times that of a normal conversation, and the existing capacity model breaks instantly. This is not “the model is too large,” but rather the unit economics have been rewritten.
2. Capacity Is Not Guesswork: Build a Reusable Estimation Model
Teams should upgrade capacity from “empirical estimation” to a “computable and regression-testable” model. There are only four core metrics: peak concurrency, average tokens per request, first-token latency target, and end-to-end latency target.
A simplified illustration (pseudocode, expressing the idea only):
# Goal: estimate required concurrent inference slotsavg_tokens = 1800 # input + expected outputtokens_per_s = 3000 # sustainable decoding throughput per slot (must come from load testing)target_qps = 120 # peak requests per second# Average slot occupancy time per requestoccupancy = avg_tokens / tokens_per_sslots_needed = target_qps * occupancy * safety_factor(1.3)
The key is that tokens_per_s and safety_factor must come from your own load tests, not copied from any public numbers. Load testing should cover three profiles: short Q&A, long documents, and multi-agent parallelism. Their resource curves are completely different, and averaging them together will seriously mislead decisions.
3. First Line of Defense: Request Tiering and Admission Control
When resources are tight, the worst approach is “first come, first served,” which lets the most expensive requests crowd out the experience of the most users. A more robust strategy is explicit tiering:
- Tier classification: divide into interactive conversation, batch tasks, and internal offline tasks based on business value and cost;
- Admission and quotas: set concurrency limits and token bucket rates for each tier; excess requests enter a queue instead of failing outright;
- Priority preemption: high-priority requests can preempt low-priority slots, and low-priority tasks are automatically downgraded to the offline queue.
Illustrative middleware logic:
def admit(req, bucket, queue):if req.tier == "interactive" and bucket.take(1):return schedule(req, priority=0)if req.tier == "batch":queue.offline.push(req) # consume later at night or during off-peakreturn accepted_deferred()return queue.wait(req, max_wait_ms=800)
4. Second Line of Defense: Routing and Graceful Degradation
“Switching to a faster mode” is essentially degradation routing. Engineering-wise, it should be a configurable policy matrix rather than a hard-coded emergency switch:
- Model tier routing: complex tasks go to the high-quality tier, simple tasks go to the lightweight tier, decided upfront by intent recognition or rules;
- Context trimming: prioritize keeping system instructions and the most recent turns, and summarize/compress history;
- Output length constraints: tighten the maximum generation length during peaks to linearly reduce occupancy time;
- Parallelism convergence: in multi-agent scenarios, converge the number of parallel subtasks from the upper limit to a medium level to avoid uncontrolled amplification.
route_policy:- match: {intent: complex, tokens_in: ">8k"}target: high_quality- match: {peak: true}target: fast_modemax_output_tokens: 512parallel_agents: 4
Degradation must be explainable to users: clearly stating that the system is in fast mode and the expected recovery time maintains trust better than silent quality reduction.
5. Third Line of Defense: Elastic Scaling and Resource Pooling
The difficulty of elasticity in inference services lies in slow cold starts: loading weights, warming up memory, and establishing caches all take time, and by the time metrics trigger an alarm and scaling begins, it is often already ten minutes too late. Feasible approaches:
- Predictive scaling: use release schedules, historical cycles (weekdays/holidays), and marketing calendars as inputs to warm up in advance;
- Resource pooling: use a container platform to host the stateless gateway and routing layer, and a heterogeneous compute pool to host different model tiers, with separate pools per tier to avoid interference;
- Queue-based peak shaving: introduce a message queue to convert burst traffic into a controllable consumption rate, and use object storage to temporarily hold intermediate results of long-document parsing;
- Cache reuse: apply prefix caching to high-frequency prefixes (system prompts, common documents) to significantly reduce repeated computation.
6. Observability: Turn “Feels Insufficient” into Metrics
Without measurement there is no capacity management. A minimal viable metrics system should include:
| Dimension | Key Metrics |
|---|---|
| Traffic | QPS, concurrency, distribution by tier |
| Cost | Token consumption per thousand requests, average cost per request |
| Latency | First-token latency P50/P95, end-to-end P99 |
| Resources | Memory usage, batch size, queue time |
| Quality | Degradation trigger rate, failure rate, retry rate |
Combined with a logging service for full-chain tracing, stringing the multiple model calls amplified from a single user request into one call tree is what lets you pinpoint whether cost overruns are caused by “excessive parallelism” or “overly long context.” Monitoring alerts should be based on leading indicators like queue time and degradation rate, rather than lagging signals like maxed-out CPU/memory.
7. Release Strategy: Move Capacity Risk Before Launch
Most incidents are not runtime problems but gaps in the release process. Four checks should be enforced:
- Capacity review: a new version must submit an explanation of per-request cost changes and a load test report;
- Canary rollout: ramp up in steps of 1% → 5% → 20%, observing queue time and degradation rate at each step;
- Complete switches: model tier, parallelism, and maximum output length must all be hot-updatable;
- Rollback plan: retain available capacity for the previous model tier so there is a fallback if the new version misbehaves.
8. External Communication: Productizing a Technical Problem
When resources are tight, what users really care about is not the cause but “can I use it now, and when will it be fixed.” Communication should include three elements: current status, temporary workaround, and recovery expectation. Giving users the choice (for example, allowing a switch to a lighter mode or deferred processing) reduces churn better than a one-sided apology. If an enterprise uses multi-cloud and multi-region deployment, it can also schedule across pools under compliance requirements to spread peak pressure across different resource pools.
9. Implementation Checklist
- Establish load test baselines for the three profiles and run a regression quarterly;
- Roll out request tiering, quotas, and priority preemption;
- Configure a hot-updatable degradation routing matrix;
- Deploy predictive scaling and message-queue peak shaving;
- Unify logging, metrics, and tracing into one observability stack;
- Write capacity review and canary rollout into the release process.
In summary, peak-hour capacity shortage is an engineerable problem: replace guessing with estimation, replace preemption with tiering, replace failure with degradation, replace brute force with elasticity, and replace feelings with measurement. Baidu AI Cloud’s combination of common capabilities in container platforms, message queues, object storage, logging services, and monitoring alerts provides a common foundation for the above approaches, on which teams can build a stable, controllable, and cost-predictable LLM inference service.
