Stability Engineering for Large Language Model Services Under Sudden Traffic Spikes
This article presents a practical framework for maintaining the stability of online large language model services during sudden traffic surges. It covers capacity planning, rate limiting, queue management, graceful degradation, gradual traffic rollout, heterogeneous hardware migration, change management, observability, alerting, incident reviews, and external communication. The goal is to turn unpredictable demand spikes into controlled, measurable operational processes.
1. Background
The workload characteristics of online large language model services differ significantly from those of traditional web services. The computational cost of each request depends on both input and output length. A long-context request may consume dozens of times more GPU memory and processing time than a short request. As a result, service capacity cannot be measured by request count alone. Token throughput, concurrent sessions, and queue length must also be considered.
When a feature receives concentrated promotion or a topic spreads rapidly through social channels, a large number of new users may arrive within a short period. Their usage patterns are often unstable: they may retry repeatedly, submit long inputs, or switch between sessions frequently. These behaviors can combine to create a sharply rising traffic curve within minutes, far exceeding the smooth growth patterns seen in normal operations.
This article does not analyze the cause of any specific incident. Instead, it breaks this type of problem into independently analyzable technical areas and presents general practices for capacity planning, traffic control, migration, deployment, and incident review.
2. Common Causes of Service Incidents
2.1 Sudden Traffic Spikes
External exposure, promotional campaigns, and feature announcements can bring several times the normal request volume within a short period. If capacity is planned only around historical averages, the resulting surge may cause queue buildup, increased timeouts, and exhausted connections.
2.2 Insufficient Capacity
The number of inference instances, the concurrency limit of each instance, and the amount of GPU memory available for caching jointly determine how many sessions the system can support. When any one of these becomes a bottleneck, the system will typically fail at that point first.
2.3 Resource Switching and Heterogeneous Migration
When an inference service is migrated to a new hardware platform in stages, the old and new resource pools will operate simultaneously for a period of time. Differences in scheduling policies, runtime versions, drivers, and operator libraries may cause the same model to deliver different throughput and latency across the two pools. If traffic allocation changes too quickly during migration, these differences can amplify the impact of an underlying problem.
2.4 Version Updates
Even a minor update to model weights, the inference engine, or pre-processing and post-processing logic can change the output-length distribution, cache hit rate, or memory usage, even when the visible functionality appears unchanged.
2.5 Manual Operations and Handoffs
Configuration drift, unsynchronized parameters, and incomplete information during on-call handoffs are common sources of operational risk. These issues can be difficult to reproduce and usually require change records and operation audits for diagnosis.
3. A Basic Approach to Capacity Planning
Capacity planning can begin with a simple model:
Required instances =Peak requests per second× Average processing time per request÷ Maximum concurrency per instance× Redundancy factor
The following points are important when selecting each value:
- Peak requests per second should be based on a high percentile from the past several weeks, with additional capacity reserved for promotional activity or major announcements.
- Average processing time should be measured separately according to input and output token counts. Request count alone is not sufficient.
- The maximum concurrency of an instance should be determined through load testing, with separate scenarios for short and long inputs.
- A redundancy factor of 1.3 to 1.5 is commonly used to accommodate instance failures, rolling updates, and traffic fluctuations.
This model is only a starting point. Reliable capacity figures come from load testing. Measure the changes in time to first token, output throughput, and GPU memory usage as concurrency increases. Identify the inflection point, and use the corresponding concurrency level as the maximum limit for a single instance.
4. Rate Limiting, Queuing, and Graceful Degradation
When capacity is insufficient, the system must actively decide how to fail. A common principle is that explicitly rejecting or queueing some requests is better than allowing all requests to time out simultaneously.
The following is a generic token-bucket rate-limiting example for controlling the number of requests admitted per unit of time:
Initialize:capacity = maximum burst sizerefill_rate = tokens added per secondtokens = capacitylast_time = current timeOn request(request):now = current timetokens = min(capacity,tokens + (now - last_time) * refill_rate)last_time = nowif tokens >= 1:tokens = tokens - 1admit the request and place it in the inference queueelse:return "Service is busy. Please try again later."Include a suggested wait time
After admission control, the system also needs explicit queueing and degradation policies:
- Set a maximum queue length. Reject requests beyond that limit to prevent wait times from growing indefinitely.
- Set an end-to-end timeout for every request. Once a request times out, release its resources promptly so abandoned requests do not continue consuming GPU memory.
- Apply tiered limits to very long inputs. During peak periods, temporarily reduce the maximum output length allowed for a single request.
- Reserve dedicated quotas for core functions so that the basic experience of existing users is not overwhelmed by an influx of new users.
5. Onboarding New Users Through Gradual Access
When a new feature or entry point is about to receive broad exposure, three preparations should be completed in advance.
First, warm up the service. Scale out ahead of time and allow instances to finish loading the model, avoiding latency fluctuations caused by cold starts.
Second, roll out access in stages. Gradually increase traffic by region, account group, or traffic percentage. Observe error rates and latency at each stage, and proceed only after the metrics remain stable.
Third, apply admission controls. Assign lower concurrency quotas to unregistered users or newly created accounts, reserving resources for established and more predictable traffic.
The shared goal of these measures is to transform an uncontrollable traffic surge into a controlled, stepwise increase.
6. Smoothing Migration Across Heterogeneous Hardware
The primary risk when migrating inference services between different hardware platforms is that the same model may not behave identically in both environments. The migration can be structured as follows:
- Establish a baseline: On the existing platform, use a fixed test set to record output, latency, and throughput.
- Run both platforms for comparison: Run the new platform with shadow traffic. Record results without returning them to users. Compare output consistency, output-length distributions, and error types.
- Shift a small percentage of traffic: Start at 1% or less, then increase the proportion in stages until the target allocation is reached.
- Define rollback thresholds: Set limits in advance for error rate, latency percentiles, and GPU memory usage. If any limit is exceeded, automatically or manually switch traffic back to the old platform.
- Keep the old resource pool available: Do not decommission the old resources until the new platform is fully stable, ensuring that a rapid rollback remains possible.
During migration, model or configuration changes should be paused. When multiple variables change at the same time, identifying the root cause becomes difficult and incident review becomes less reliable.
7. Canary Releases and Change Management
Every change should be independently attributable. Recommended practices include:
- Each change should contain only one category of modification, such as updating model weights or adjusting scheduling parameters, but not both at once.
- Document the expected impact and rollback procedure before making a change.
- Use canary releases. Initially route traffic to a small number of instances, observe a complete business cycle, and then expand the rollout.
- Place all configuration under version control to avoid directly modifying production parameters.
8. Observability and Alerting
Stability management depends on metrics that accurately and promptly reflect system state. At a minimum, monitoring should cover the following areas:
- Request layer: Requests per second, success rate, and the percentage of requests subject to rate limiting.
- Latency layer: P50, P95, and P99 time to first token and end-to-end latency.
- Generation layer: Output tokens per second and the distribution of output lengths.
- Resource layer: GPU memory usage, compute-unit utilization, queue length, and queueing time.
- Business layer: Availability of core functions and user retry rate.
Alerts should be based on trends rather than isolated samples. For example, queueing time remaining above a threshold for five consecutive minutes is more meaningful than a single out-of-range sample. Each alert should also have a corresponding runbook that specifies what to check first, who makes the decision, and when to roll back.
9. Incident Reviews and External Communication
After each incident, prepare a review report that includes the timeline, impact scope, root cause, response process, and improvement items. The focus should be on system-level deficiencies rather than assigning personal blame.
External communication should also follow a consistent process. When the root cause has not yet been confirmed, describe only verified symptoms and the affected scope, and state that investigation is ongoing. Rumors, assumptions, and informal information should be treated as unverified hypotheses and must not be adopted directly as conclusions in the incident review.
