LLM Inference Service Outages: Root Cause Analysis and Stability Engineering Practices

    In large model inference, most user-reported "outages" are not process crashes but quality degradation below a usable threshold. This article breaks down the real root causes across compute supply, KV Cache memory pressure, scheduling and batching side effects, cache hotspots, and dependency chains. It shows how to turn "it feels slow" into computable capacity metrics, how to build overload protection that fails gracefully instead of collapsing, and how to design elasticity, observability, and failure drills. Readers will learn to align user-perceived symptoms with backend metrics, estimate KV Cache memory growth, plan capacity by P95 with headroom, and validate degradation paths through regular exercises.

    1. First, Clarify the Concept: What Users Call a “Crash” Is Usually Not Downtime

    In large model inference, most “service anomalies” reported by users are not a full process exit, but service quality degrading below a usable threshold. Typical symptoms include: time to first token (TTFT) rising from a few hundred milliseconds to over ten seconds, streaming output stalling midway, requests timing out after queuing, and some users succeeding while others fail.

    The underlying nature of these symptoms is a queuing theory problem: when the arrival rate approaches or exceeds the system service rate, queue length and wait time grow non-linearly. Inference services are especially sensitive because a single request occupies resources for a long time (generating tens to thousands of tokens), and those resources cannot be effectively partitioned and reused. So the first step in judging “did it really crash” is to align user-side perception with backend metrics, rather than rushing to restart or scale out.

    Start by building an alignment table:

    User perception Likely real backend state First metric to check
    Spinning with no response Requests piling up at the gateway or scheduling queue Queue length, queue wait time
    Slow first token but normal afterward Compute queuing in the prefill stage TTFT, batch wait time
    Output stops midway Single-card memory exhaustion triggering swap-out or timeout Memory usage, KV Cache eviction rate
    Some users can use it Inconsistent state across AZs/replicas Replica health, per-region success rate

    2. Root Cause Layering: From Compute Supply to Cache Amplification

    2.1 Rigid Constraints of the Compute Supply Layer

    Inference compute cannot scale horizontally and cheaply on CPU the way a stateless web service can. Tight accelerator supply, long delivery cycles, and uneven spare capacity across regional pools all mean that when a peak arrives, “having money is not enough to buy cards.” Some early teams relied on overseas or third-party spare compute as a buffer; once upstream supply tightened, that cushion vanished immediately. The correct engineering approach is to acknowledge that compute is a finite, long-lead-time resource and to design elasticity up front, rather than pinning stability on temporary resources.

    2.2 Model Size Sets the Memory Floor

    The larger the model, the more weights reside permanently in memory, compressing the space available for KV Cache. KV Cache is the key-value cache for contextual attention, and its usage is proportional to number of layers, attention head dimension, sequence length, and concurrency. A rough estimation logic is:

    1. def kv_cache_bytes(layers, kv_heads, head_dim, seq_len, batch, dtype_bytes=2):
    2. # Each layer caches both K and V per token
    3. per_token = 2 * layers * kv_heads * head_dim * dtype_bytes
    4. return per_token * seq_len * batch
    5. # Example: memory amplification under long context + high concurrency
    6. print(kv_cache_bytes(64, 8, 128, seq_len=32000, batch=32) / 1024**3, "GiB")

    This calculation reveals a frequently overlooked fact: context length and concurrency are multiplicative. Raising the context window from 4K to 32K increases KV Cache demand eightfold at the same concurrency. When memory runs short, the system can only reduce batch size, reject new requests, or swap out frequently, which users immediately experience as “stuck.”

    2.3 Side Effects of Scheduling and Batching Strategies

    To improve throughput, inference frameworks commonly use continuous batching. It brings high utilization, but it also means long requests keep occupying slots while short requests get “starved.” Without request prioritization and preemption, a single long document-summarization task can drag down the overall interactive experience.

    2.4 Cache Amplification and Hotspot Concentration

    When many users submit highly similar prompts (e.g., the same template or the same long document queried repeatedly), prefix caching improves hit rate but causes hotspot shard concentration: a few replicas get maxed out while the rest sit idle. Overall utilization looks low, yet users still feel stuck. This kind of problem needs consistent hashing and hotspot spreading to mitigate.

    2.5 Dependency Chains and Network Jitter

    Gateway rate-limit thresholds, message queue backlogs, blocked log and monitoring reporting, and cross-AZ bandwidth fluctuations all amplify the failure radius at peak times. Any synchronous blocking side call (such as content safety review or billing/metering) can become a bottleneck and must be made asynchronous with an independent timeout.

    3. Capacity Planning: Turning “It Feels Slow” into Computable Metrics

    Capacity planning should output three numbers: target QPS, safe concurrency per replica, and required replica count.

    1. Safe concurrency per replica ≈ memory allocated to KV Cache / average KV Cache per request
    2. Required replicas ≈ peak QPS × average generation time / safe concurrency per replica × redundancy factor (1.3~1.5)

    The key discipline: plan by P95, not by the average, and keep at least 30% headroom for bursts. Load testing must include three traffic models—short question/short answer, long context, and burst spikes—and must measure the “performance inflection point” rather than only maximum throughput. Beyond the inflection point, throughput barely increases while latency rises sharply; that point is the true capacity ceiling.

    4. Overload Protection: Better to Reject Than to Avalanche

    The core of stability engineering is not “never fail” but controllable failure. Set four gates at the gateway and inference layers:

    1. Concurrency semaphore: cap in-flight requests and fail fast on overflow to avoid lengthening the queue.
    2. Priority queue: prioritize paid/interactive requests; downgrade offline batch tasks to low priority and make them preemptible.
    3. Adaptive rate limiting: dynamically adjust the admission rate based on measured latency rather than a static threshold.
    4. Graceful degradation: disable non-core capabilities (such as complex reasoning modes or ultra-long context) while keeping basic chat available.

    Illustrative implementation (pseudocode to explain the control logic):

    1. import asyncio, time
    2. class OverloadGuard:
    3. def __init__(self, max_inflight, rate, burst):
    4. self.sem = asyncio.Semaphore(max_inflight)
    5. self.tokens = burst
    6. self.rate = rate
    7. self.ts = time.monotonic()
    8. def _refill(self):
    9. now = time.monotonic()
    10. self.tokens = min(self.tokens + (now - self.ts) * self.rate, self.rate * 2)
    11. self.ts = now
    12. async def acquire(self):
    13. self._refill()
    14. if self.tokens < 1:
    15. raise RuntimeError("rate_limited") # Fail fast, return a retryable hint
    16. self.tokens -= 1
    17. await self.sem.acquire()
    18. def release(self):
    19. self.sem.release()

    Companion requirement: all downstream calls must set a timeout that is independent and shorter than the user timeout, and implement a limited number of exponential-backoff retries; retries must include jitter, otherwise they form a synchronized secondary shock (a retry storm).

    5. Elasticity and Deployment Architecture

    • Multiple replicas + cross-AZ: avoid single points of failure and keep replicas capability-homogeneous for unified scheduling.
    • Metric-driven autoscaling: use “in-flight requests, queue wait time, memory usage” as scaling signals, which track real inference load better than CPU utilization; also set a scale-in cooldown window to prevent flapping.
    • Model warm-up and residency: large model loading is slow, so a scaled-out instance must finish warm-up before taking traffic; otherwise a new replica coming online actually worsens congestion.
    • Request-to-replica affinity: prefix cache hits depend on affinity, so make an explicit tradeoff between “load balancing” and “cache hit rate,” and spread hotspot shards.
    • Asynchronous side paths: decouple review, metering, and auditing through a message queue, allowing delayed persistence at peak instead of blocking the main path.

    6. Observability: You Can Only Govern What You Can See

    Build a layered metrics system, none of which can be missing:

    • User experience layer: TTFT, per-token output latency (TPOT), end-to-end success rate, timeout rate.
    • Service layer: queue length, queue wait time, rejection rate, batch size distribution, preemption count.
    • Resource layer: accelerator utilization, memory usage and fragmentation, KV Cache hit rate and eviction rate, cross-region bandwidth.
    • Dependency layer: gateway error rate, message queue backlog, side-path service latency.

    Alerts should be based on multi-metric combinations and period-over-period comparisons rather than a single threshold, to avoid alert storms at peak. Logs and tracing must support correlating the full “gateway—scheduler—inference—side path” chain by request ID; this is the only reliable means of locating bottlenecks during postmortems. In the cloud, these capabilities are typically carried by general-purpose categories: a container platform handles elastic orchestration, object storage holds models and datasets, a message queue handles peak shaving and decoupling, and log services with monitoring complete the observability loop. General cloud product categories offered by providers such as Baidu AI Cloud can serve as the foundation for such an architecture, but specific choices should be based on your own load-testing results.

    7. Failure Drills and Postmortem Mechanisms

    Stability is built through practice. Run drills regularly: randomly terminate replicas, inject memory pressure, simulate upstream rate limiting, lengthen a single request’s context, and create cache hotspots. The goal of a drill is not to “prove the system won’t crash” but to verify that degradation paths take effect as expected and that alerts fire before user complaints.

    Postmortems must uphold a blameless culture, with a fixed output of four items: impact scope and duration, the triggering chain, which protection mechanisms worked and which failed, and verifiable improvement items (with owner and deadline). Improvement items must be measurable, for example “P95 TTFT stays under 2 seconds at 3x peak traffic.”

    8. Conclusion

    The “suspected crashes” of large model services are, in the vast majority of cases, predictable results of imbalance among capacity, memory, and scheduling. Calculate the multiplicative cost of context length and concurrency clearly, put overload protection at the gateway, replace scaling signals with real load metrics, extend observability down to the KV Cache level, and validate degradation paths through regular drills—and service availability shifts from depending on luck to depending on engineering discipline.