Building High Availability for LLM Inference Services: Stability Lessons from Sudden Failures
This article explains how to design reliable large language model inference services under traffic spikes, resource constraints, dependency failures, and risky changes. It covers redundancy, rate limiting, queuing, graceful degradation, timeouts, retries, circuit breakers, capacity planning, observability, release management, and incident response.
1. Why Online AI Services Fail
Online AI services differ from traditional web applications. A single request may pass through authentication, queuing, inference, and streamed response delivery. Each request typically consumes more compute resources and takes longer to complete. When traffic increases sharply or a dependency slows down, the problem can spread and amplify along the call chain.
Common triggers include:
- Traffic spikes: Breaking news, product launches, or external exposure can multiply request volume within minutes.
- Resource bottlenecks: GPUs, memory, or network bandwidth become saturated, forcing new requests to wait.
- Dependency failures: Slow authentication services, configuration centers, or data stores can delay the main request path.
- Change-related risk: Configuration updates, model upgrades, or service releases may introduce behavior that has not been sufficiently tested.
The goal of reliability engineering is not to eliminate every failure. It is to limit the impact of failures, shorten recovery time, and prevent similar incidents from happening again.
2. Common Failure Modes
In practice, service incidents usually fall into several categories, each requiring a different response.
- Complete outage: The entry point or a critical dependency fails entirely, causing all requests to fail.
- Partial outage: Only a region, API category, or group of users is affected.
- Performance degradation: Requests still complete, but latency continues to rise and timeouts become more frequent.
- Protective rejection: The system returns a message such as “service busy.” This is the result of an intentional protection mechanism.
Distinguishing these failure modes is important for operations teams. A complete outage generally requires traffic to be redirected first. During performance degradation, rate limiting and graceful degradation are usually more appropriate to prevent the backend from being overwhelmed.
3. High-Availability Architecture
The foundation of high availability is eliminating single points of failure. This can be addressed at three levels.
Redundant access layer: Deploy entry-point load balancers in at least two availability zones and configure health checks. When a node fails, it should be automatically removed from service without manual intervention.
Redundant service layer: Run stateless API services with multiple replicas distributed across different failure domains. Stateful components should use primary-standby or multi-replica replication, with clearly defined failover conditions and timeout values.
Dependency isolation: Separate core and non-core functions. For example, conversation history and analytics should not share thread pools or connection pools with the inference path. Otherwise, instability in a non-critical feature can directly affect the primary service.
In cloud environments, common infrastructure capabilities such as object storage, message queues, container platforms, logging services, and monitoring systems can be used to implement redundancy, elastic scaling, and fault isolation through concrete configurations.
4. Rate Limiting, Queuing, and Graceful Degradation
When traffic exceeds system capacity, continuing to accept every request only makes all requests slower. The correct approach is to control how much traffic enters the system and reserve limited resources for requests that can still complete successfully.
The token bucket is a commonly used rate-limiting algorithm. The system generates tokens at a fixed rate, and each request consumes one token. When no tokens remain, the request is rejected or placed in a queue.
class TokenBucket:capacity // Bucket capacity, which controls the allowed burst sizerate // Number of tokens added per secondtokens = capacitylast_time = now()function allow():elapsed = now() - last_timetokens = min(capacity, tokens + elapsed * rate)last_time = now()if tokens >= 1:tokens = tokens - 1return truereturn false
Graceful degradation means proactively disabling non-essential features when resources are under pressure. Examples include pausing deep processing for long inputs, reducing the maximum context length, or disabling non-critical auxiliary analytics.
Degradation policies should be designed in advance and documented in operational runbooks. Each policy should specify its trigger conditions, activation method, and recovery criteria. This avoids making ad hoc decisions during an incident.
5. Circuit Breaking, Timeouts, and Retries
When a dependency becomes slow, continuously waiting and retrying can amplify the problem. Three mechanisms should be used together.
Timeouts: Every remote call must have a timeout. The timeout should be slightly longer than the dependency’s normal P99 latency, but it must not exceed the total wait time users can reasonably tolerate.
Limited retries: Retries should be used only for idempotent operations. They are typically limited to one or two attempts, with exponential backoff and random jitter to prevent many requests from retrying at the same time.
Circuit breakers: When the failure or timeout rate of a dependency exceeds a threshold within a measurement window, the circuit breaker opens and returns a fallback response directly. After a cooling period, a small number of probe requests are allowed through. If they succeed, the circuit returns to the closed state.
class CircuitBreaker:state = CLOSEDfailure_count = 0function call(request):if state == OPEN:if cooldown_passed():state = HALF_OPENelse:return fallback(request)try:result = invoke(request, timeout = TIMEOUT)on_success()return resultexcept Failure:on_failure()return fallback(request)
Circuit-breaker thresholds should be based on historical data rather than copied from fixed values chosen by experience alone.
6. Capacity Planning and Traffic-Spike Response
The key to capacity planning is understanding how many requests a unit of resource can handle. Teams should continuously measure the following metrics and build a scaling model that matches business growth:
- Requests per second and maximum concurrency per instance;
- Average and tail latency for different request lengths;
- Resource-utilization ranges during peak periods;
- The time from triggering a scale-out operation to the point when a new instance can serve traffic.
For predictable peaks, such as a product launch or a scheduled campaign, capacity should be expanded and instances warmed up in advance.
For unexpected surges, autoscaling provides only a limited buffer. Rate limiting and graceful degradation are still required as the final protection layer. If scaling takes longer than traffic growth, the system must rely on these two mechanisms to protect core services.
7. Observability and Alerting
Without measurements, it is impossible to determine whether a system is healthy. Observability generally includes three types of data: metrics, logs, and distributed traces.
At a minimum, monitoring should cover:
- Success rates and error-code distributions;
- Average latency and P95/P99 latency percentiles;
- Queue length and the number of rejected requests;
- Circuit-breaker state changes;
- Response time and failure rates for critical dependencies.
Alerting rules should focus on user-visible impact rather than a single infrastructure metric. For example, “success rate below a threshold for three consecutive minutes” is usually more meaningful than “CPU utilization above 80%.”
Alerts should also be assigned severity levels, owners, and response deadlines. This helps prevent alert fatigue from causing important signals to be ignored.
8. Release and Change Management
Many production incidents are caused by changes. A stable release process usually follows these principles:
- Canary releases: Validate the change on a small portion of traffic before gradually increasing its exposure.
- Fast rollback: Prepare a rollback plan before every release and verify that it works.
- Change windows: Avoid peak periods and reduce the number of simultaneous changes.
- Configuration audits: Configuration changes require the same review and tracking discipline as code changes.
During a canary release, compare the success rate and latency of the new and old versions. If either metric deteriorates beyond a defined threshold, the rollout should be paused automatically.
9. Incident Response and Postmortems
The response process after an incident begins can determine the scale of the damage. A practical response can be divided into three stages.
Mitigation: Restore service as quickly as possible by redirecting traffic, enabling degradation policies, or rolling back a change. Finding the root cause is not the priority at this stage.
Investigation: Compare the incident timeline with change records, metric trends, and logs to progressively narrow the scope of the problem.
Postmortem: Produce a written report covering the timeline, impact, root cause, improvement actions, and owners. The purpose of a postmortem is to identify process and system weaknesses, not to assign personal blame.
Every improvement action should be added to subsequent engineering work and validated in the next resilience exercise.
10. Conclusion
The reliability of LLM inference services depends on a set of coordinated mechanisms. Redundancy removes single points of failure. Rate limiting and graceful degradation protect capacity boundaries. Timeouts, retries, and circuit breakers prevent failures from spreading. Capacity planning and observability help teams identify risks earlier, while disciplined release processes and postmortems create a continuous improvement loop.
There is no shortcut to building these capabilities. Teams should start with a complete failure exercise, verify that each mechanism actually works, and then gradually improve their runbooks and automation.
