Why LLM Services Crash Under High Concurrency: Causes and Stability Practices
This article explains why large language model (LLM) services often become unavailable just as adoption grows, and how to keep them stable. It breaks down the root causes, from the unique constraints of inference resources to homogeneous requests that amplify wasted computation and the absence of backpressure and admission control. It then presents a four-layer stability design covering capacity planning based on concurrent tokens, admission control with graceful queuing, context reuse and caching, and degradation with multi-queue isolation. It also covers cost governance through observability, plus metrics, logging, alerting, and load testing. The goal is to help teams balance user experience and cost so that useful tools keep serving more users reliably.
1. The Problem: Why “Ease of Use” Can Overwhelm a Service
Once a class of AI coding tools or LLM services genuinely lowers the barrier to use, demand on the request side rises quickly. Work that used to require writing integration code, understanding authentication and parameters, and handling streaming responses is now packaged into an out-of-the-box interactive experience, so even non-expert users benefit directly. This “usability dividend” has two immediate consequences:
- Request volume grows non-linearly in a short period, with concentrated peaks.
- Request shapes are highly homogeneous, with many requests repeating the same prompt prefixes and context fragments.
As a result, before the server side has finished scaling capacity, it starts to show longer queues and more timeouts, and eventually appears to users as “the service is unavailable again.” It is worth stressing that this is a capacity and traffic governance problem, not the failure of a single feature.
2. Root Causes: From Traffic Patterns to Resource Bottlenecks
2.1 The Special Nature of Inference Resources
Unlike stateless web APIs, the concurrency of LLM inference is constrained jointly by GPU memory capacity, batching efficiency, and context length. The longer the context, the more GPU memory each request consumes and the fewer requests can be processed in parallel. This is why “average QPS is not high but the service crashes” is a common phenomenon. What truly determines capacity is the concurrent token volume, not the number of requests.
2.2 Homogeneous Requests Amplify Wasted Computation
Many requests share the same system prompt, tool descriptions, and code snippets. Without a prefix reuse mechanism, this part of the context must be recomputed every time, so compute is repeatedly spent on content that does not change.
2.3 Missing Backpressure and Admission Control
When the entry point has no rate limiting or queue limit, excess requests keep occupying connections and memory, slowing down healthy instances and letting a local failure spread into a full outage.
3. Stability Design: Four Layers of Defense
Layer 1: Capacity Planning and Elastic Scaling
Use “concurrent tokens” rather than QPS as the core capacity metric, set a redundancy factor based on historical peaks, and configure scaling policies based on queue length and time-to-first-token.
Capacity estimation (illustrative)Required concurrency ≈ peak requests × average context length ÷ batching windowReserved redundancy = required concurrency × 1.5
Layer 2: Admission Control and Graceful Queuing
Set token-bucket rate limiting, a maximum queue time, and a fast-fail policy at the entry point, so excess requests return a retryable response early instead of dragging down the whole system.
# Illustrative code: priority-aware admission controlclass Admission:def __init__(self, rate, max_queue=200):self.tokens = rateself.max_queue = max_queueself.queue = []def allow(self, req):if self.tokens <= 0 or len(self.queue) >= self.max_queue:return "reject" # fast fail, return retryableself.tokens -= 1self.queue.append(req)return "accept"
Layer 3: Context Reuse and Caching
Enable prefix caching for stable prefixes such as system prompts, tool descriptions, and long documents; build a result cache for fully identical requests with a reasonable expiration time; and for semantically similar questions, reuse retrieval results to reduce repeated computation.
Layer 4: Degradation and Multi-Queue Isolation
Isolate interactive requests from batch jobs in separate queues so long-running tasks do not crowd out the interactive path; under high pressure, automatically degrade to shorter contexts and disable non-essential tool calls to keep the main path available.
4. Cost Governance: Turning Credits and Bills into Observable Metrics
One of the core pain points in the original feedback is that “the same work can cost tens of times more.” This is essentially caused by an opaque invocation path: when users call through multiple layers of wrapping, intermediate steps may add a relatively high markup, whereas direct, transparent usage-based billing is often significantly lower. Governance recommendations:
- Build usage dashboards by user, by scenario, and by model to locate high-consumption sources.
- Force high-frequency repeated requests through the cache, and include the hit rate in evaluation.
- Reduce average token count through context trimming and summary compression.
- Show estimated consumption on the client so users have cost expectations.
- Regularly reconcile bills against actual usage to identify abnormal amplification.
Cost observability fields (illustrative)request_id, scene, model, prompt_tokens, cached_tokens, latency_ms, cost
5. Observability and Drills
Stability cannot rely on architecture alone; it also depends on data and drills:
- Metrics: queue length, time-to-first-token, overall latency, cache hit rate, error rate, and per-request token distribution.
- Logs: structured records of the request path and degradation flags for easier tracing.
- Alerting: use latency and error rate as the primary signals, avoiding CPU-only alerts.
- Drills: regularly run peak load tests and dependency fault injection to verify that rate limiting and degradation actually work.
6. Combining General Cloud Capabilities
In a cloud environment, the solution above can be built from general-purpose capability categories: a container platform to host inference services with elastic scaling, load balancing and message queues to handle queuing and peak shaving, object storage for models and static assets, a caching service to support prefix and result reuse, and logging plus monitoring and alerting to close the observability loop. Baidu AI Cloud offers these general capability categories, which can be combined flexibly according to business peaks, but specific specifications and pricing should be based on the official documentation.
7. Conclusion
When a service becomes unavailable under high concurrency, it is usually not that the “capability is lacking,” but that traffic governance and cost transparency have not kept up with the usability dividend. Switching the capacity metric to concurrent tokens, adding admission control at the entry point, caching repeated context, and turning cost into a dashboard can balance experience and cost, so a genuinely useful tool keeps serving more users reliably.
