LLM Service Outages: Stability Design Under High Concurrency

    This article explores the root causes and resolution strategies for sudden anomalies in Large Language Model (LLM) inference services under high concurrency. It provides a comprehensive guide covering fault categorization, a layered troubleshooting workflow, token-based rate limiting, degradation, circuit breaking, client retry strategies, and capacity planning to ensure robust service stability.

    1. Background: User Perception vs. Server Reality

    When service anomalies occur, users typically experience similar symptoms: the application fails to load, conversations drop midway, or responses hang indefinitely. However, the underlying causes vary significantly. It could be normal business growth exceeding estimated capacity, a dependency component failure, a defect introduced by a change, or abnormal traffic consuming resources.

    Speculations often found on social platforms lack evidence, such as claims of “intentional traffic manipulation” or “resource exhaustion during a confrontation.” Such judgments cannot serve as a direct basis for remediation. Teams should first verify the facts using metrics, logs, and tracing before deciding on a course of action. The methods discussed in this article apply to any user-facing online service, especially compute-intensive inference services with long per-request processing times.

    2. Common Classifications of Anomalies

    Before troubleshooting, categorize potential causes to verify them one by one:

    1. Instant Traffic Spikes: Includes marketing campaigns, hot events, or concentrated usage following a new version push. Client-side automatic retries after timeouts further amplify request volumes, creating a retry storm.
    2. Abnormal or Malicious Traffic: Includes automated script high-frequency calls, batch scraping, and account sharing or abuse. Typical characteristics include request frequencies from specific sources far exceeding normal users, highly similar request content, or fixed request parameter patterns.
    3. Resource Exhaustion: Includes GPU VRAM depletion, continuous inference queue buildup, connection pool or file handle exhaustion, and database connection limits. Resource exhaustion is rarely sudden; queue length and wait times typically show a gradual upward trend first.
    4. Dependency Failures: Includes slow responses from authentication services, object storage access failures, message queue accumulation, and DNS resolution anomalies. The impact of a dependency failure can extend beyond its own module.
    5. Deployments and Configuration Changes: Includes new model version switches, configuration parameter modifications, incorrect canary release ratios, and incomplete rollbacks. A characteristic of change-related issues is a high alignment between the failure timestamp and the change timestamp.

    The goal of categorization is to narrow down the troubleshooting scope. Teams should determine the primary direction within minutes of a failure, rather than wavering among all possibilities.

    3. Layered Troubleshooting Workflow

    It is recommended to troubleshoot in the following order, with each step yielding a clear conclusion.

    3.1 Confirm the Impact Scope

    First, answer three questions: Which client types are affected? Which regions or nodes are affected? Which APIs are affected? If only a specific client version has issues, prioritize suspecting client compatibility or deployment problems. If all clients are affected simultaneously with no significant difference between APIs, it is more likely a shared dependency or global resource issue.

    3.2 Review Core Metrics

    Focus on the following metrics:

    • Request volume (QPS) compared to historical periods
    • Success rate and error code distribution, distinguishing between timeouts, rate limits, and internal server errors
    • Latency percentiles (e.g., P50, P95, P99); tail latency degradation usually exposes problems earlier than averages
    • Queue wait time and depth
    • GPU utilization, VRAM usage, CPU and memory watermarks
    • Dependency service call success rates and latency

    If request volume hasn’t significantly increased but queue wait times continue to rise, the problem likely lies in capacity or processing efficiency. If request volume spikes and the growth is concentrated among a few sources, prioritize traffic governance.

    3.3 Check Recent Changes

    Align the failure timeline with deployment records, configuration change logs, and model or data version switch records. Most sudden failures can find clues in the change logs. If a suspicious change exists, prioritize rolling it back before conducting an in-depth analysis. Rollbacks carry relatively low risk and can quickly validate the hypothesis.

    3.4 Stop the Bleeding Before Root Cause Analysis

    When the root cause is uncertain, take measures to reduce the impact first, such as:

    • Implementing rate limiting or temporary bans on abnormal sources
    • Disabling non-core features to ensure main path availability
    • Scaling out or increasing concurrency limits
    • Rolling back recent changes

    Root cause analysis can be performed after service recovery. Spending an extra minute arguing about the cause during a failure usually results in an extra minute of inconvenience for users.

    3.5 Post-Mortem

    The post-mortem should include the timeline, impact scope, root cause, remediation process, action items, and responsible parties. Action items must be measurable and trackable, such as “add a timeout drop policy for the inference queue and complete validation within two weeks,” rather than vague statements like “improve monitoring.”

    4. Rate Limiting: Controlling Inbound Request Volume

    The goal of rate limiting is to ensure the quality of accepted requests when capacity is exceeded, rather than allowing all requests to slow down or fail together. Common algorithms include fixed window, sliding window, leaky bucket, and token bucket. The token bucket is well-suited for online services because it limits the average rate while allowing a certain degree of short-term bursts.

    Below is a token bucket implementation supporting weight-based deduction, where weight can represent resource consumption differences across requests:

    1. import threading
    2. import time
    3. class TokenBucket:
    4. """Token bucket rate limiter: replenishes tokens at a fixed rate, allows limited burst traffic."""
    5. def __init__(self, rate: float, capacity: float):
    6. self.rate = rate # Tokens replenished per second
    7. self.capacity = capacity # Bucket capacity, determines the maximum allowed burst
    8. self.tokens = capacity
    9. self.updated_at = time.monotonic()
    10. self.lock = threading.Lock()
    11. def acquire(self, cost: float = 1.0) -> bool:
    12. with self.lock:
    13. now = time.monotonic()
    14. elapsed = now - self.updated_at
    15. self.tokens = min(self.capacity, self.tokens + elapsed * self.rate)
    16. self.updated_at = now
    17. if self.tokens >= cost:
    18. self.tokens -= cost
    19. return True
    20. return False

    In actual deployment, rate limiting should be layered: the gateway layer controls the global total, the user or tenant layer controls individual quotas, the API layer protects high-cost interfaces, and the IP layer defends against obvious abnormal sources. Thresholds at different layers are independent. Triggering any layer should return a clear error code with a retry-after hint.

    5. The Uniqueness of Generative Services

    Inference services differ significantly from standard CRUD APIs, mainly in three aspects:

    First, long per-request processing time. A single generation may take several seconds to tens of seconds, and the number of requests a single instance can handle concurrently is limited. Second, large variance in resource consumption between requests. Longer inputs and outputs consume more compute and VRAM. Third, pronounced queueing effects. As concurrency approaches the limit, wait times increase rapidly, triggering client timeouts and retries.

    Therefore, rate limiting by request count is often insufficiently precise. A more reasonable approach is to estimate cost based on compute or token count and perform admission control accordingly. The following code demonstrates this concept; the weight coefficients are illustrative, and actual values must be calibrated through load testing.

    1. def estimate_cost(input_tokens: int, max_output_tokens: int) -> float:
    2. """Estimate the relative cost of a single request. Weights need to be calibrated based on load test results, shown here for illustration only."""
    3. prefill_weight = 0.2 # Relative cost of the input part
    4. decode_weight = 1.0 # Relative cost of the output part
    5. return input_tokens * prefill_weight + max_output_tokens * decode_weight
    6. def admit(bucket, input_tokens: int, max_output_tokens: int) -> bool:
    7. cost = estimate_cost(input_tokens, max_output_tokens)
    8. return bucket.acquire(cost)

    In addition to rate limiting, the following hard boundaries should be set:

    • Maximum input length and maximum output length per request
    • Queue timeout threshold; requests waiting beyond the threshold should fail directly to avoid occupying subsequent resources
    • Maximum concurrency per user

    These boundaries prevent individual extra-long requests from overwhelming an entire instance.

    6. Degradation and Circuit Breaking: Ensuring Core Paths

    Rate limiting addresses “how much comes in,” while degradation addresses “what to keep when capacity is exceeded.” Common degradation strategies include:

    1. Disabling non-core features, such as recommendations, auto-complete, and history sync.
    2. Shortening the context window or reducing the maximum output length per request to achieve higher throughput.
    3. Returning cached content directly for cacheable results.
    4. Returning queue prompts to users when the queue is too long, rather than letting requests wait indefinitely.

    Circuit breaking is used to handle dependency failures. When a dependency’s error rate exceeds a threshold, the caller should fail fast instead of continuously waiting for timeouts. After a cooldown period, the circuit breaker enters a half-open state, allowing only a small number of probe requests. If the probes succeed, calls resume; if they fail, the breaker remains open. Circuit breaker state transitions must have logs and metrics; otherwise, operators cannot determine if protection is currently active.

    7. Client Retry Strategies

    Many failures are amplified due to client retry logic. If all clients time out and retry simultaneously, the server receives multiples of the normal request volume in a short period.

    The recommended approach is exponential backoff with random jitter and a maximum retry limit. The following example demonstrates this pattern:

    1. import random
    2. import time
    3. class TransientError(Exception):
    4. """Represents a retryable temporary error, such as a timeout or temporary service unavailability."""
    5. def call_with_backoff(fn, max_retries: int = 4, base: float = 0.5, cap: float = 8.0):
    6. for attempt in range(max_retries + 1):
    7. try:
    8. return fn()
    9. except TransientError:
    10. if attempt == max_retries:
    11. raise
    12. delay = min(cap, base * (2 ** attempt))
    13. time.sleep(random.uniform(0, delay)) # Full jitter, dispersing retry times

    Additionally, retry operations must be idempotent. For requests with side effects, use a request identifier for deduplication to avoid duplicate billing or data writes caused by retries.

    8. Monitoring and Alerting Design

    The value of monitoring lies in discovering problems before users complain en masse. It is recommended to cover at least the following categories of metrics:

    • Traffic: Total request volume, per-API request volume, per-source request volume
    • Quality: Success rate, error code distribution, P95 and P99 latency
    • Capacity: Queue wait time, queue depth, GPU utilization, VRAM usage
    • Dependencies: Call success rate and latency for each dependency

    Alerting strategies should be based on trends and durations rather than single sample points. For example, “P99 latency exceeds twice the baseline for five consecutive minutes” is more meaningful than “latency exceeded the threshold for one second.” The former better reflects actual impact and yields fewer false positives. Alerts should be tiered by severity with clear definitions for the responsible person and response time.

    9. Capacity Planning and Cost Balancing

    Capacity planning needs to answer two questions: how many resources are required at peak, and how much cost is paid for it normally.

    Little’s Law from queueing theory can be used for rough estimation: the number of requests in-flight in the system equals the request arrival rate multiplied by the average processing time. Assuming a peak of 50 new requests per second and an average processing time of 4 seconds, the concurrent in-flight requests are approximately 200. If a single instance can handle a maximum of 16 concurrent requests, the base number of instances is 200 divided by 16, which is about 13. Considering a 30% buffer, deploying about 17 instances is recommended.

    The above numbers are only to illustrate the calculation method; actual values must be determined through load testing and historical traffic data. When planning, also consider the following factors:

    • Auto-scaling startup time. Cold starts for GPU instances can take several minutes and cannot handle second-level traffic spikes, so a certain base capacity must be maintained.
    • Peak-to-average ratio. When business has clear time-of-day or event-driven fluctuations, design base capacity for peaks and use elastic resources to cover the excess.
    • Marginal cost changes. The cost of redundant resources must be weighed against the losses caused by failures, rather than simply pursuing zero downtime.

    10. External Communication Principles

    During an outage, users are most concerned about when service will be restored and the scope of the impact. External announcements should be timely, accurate, and restrained. It is recommended to include the following:

    1. Confirmed symptoms and impact scope
    2. Current remediation status
    3. The time for the next update

    Announcements should not speculate on unverified causes or blame third parties. Once the root cause is confirmed, explain it to users along with improvement measures through a post-mortem report. This maintains trust and avoids the passivity of subsequent clarifications.