High Availability Practices and Stability Governance for LLM APIs

    This article explains how to measure and improve the availability of large language model APIs in production. It covers defining success rate and latency metrics, separating rate limits from server errors, building layered redundancy with multi-provider routing, circuit breaking, request prioritization, and idempotency, applying correct retry and timeout strategies for streaming output, governing multi-capability interfaces, and running observability and failure drills. The goal is to turn availability targets into an executable architecture.

    1. Introduction: Why “Nines” Are a Hard Selection Criterion

    When integrating LLM capabilities into production systems, teams usually focus on quality metrics first, yet what really shapes the online reputation is availability. Status data from one platform between August and October showed roughly 99.46% availability for deep-reasoning endpoints and about 99.74% for general chat endpoints. Converting these percentages into time makes the gap clearer: a year has 8,760 hours, so 99.46% corresponds to about 47.3 hours of downtime, while 99.74% corresponds to about 22.8 hours. These numbers show that the difference between “two nines” and “three nines” is not rhetorical; it is a perceptible gap of tens of times per month.

    The structure of failures matters even more than the average. A single outage lasting more than four hours affected the web app, mobile chat, and both API types at the same time, making it the widest and longest incident; most other incidents lasted only minutes to tens of minutes, and some affected only search-related add-on tools while basic chat kept working. Stability governance therefore has to track two curves at once: the long-term average of availability, and the duration and blast radius of each individual incident.

    2. Translating Availability into Engineering Language

    Availability should not be taken from marketing claims; you need to define and measure it yourself. Three categories of metrics are worth separating:

    • End-to-end success rate: the share of requests that receive a complete response from the client, including network and rate-limiting factors.
    • Server-side success rate: the share after excluding client errors, used to assess the provider’s real capability.
    • Latency percentiles: P50/P95/P99 time to first byte and total completion time; in long-text generation, P99 often hurts the experience more than the average.

    A schematic aggregation logic can be written as:

    1. # Illustrative only: aggregate per minute and separate error types
    2. bucket = {
    3. "total": 0, "ok": 0,
    4. "rate_limited": 0, # 429, a capacity issue
    5. "server_error": 0, # 5xx, an availability issue
    6. "timeout": 0, # client timeout, needs separate tracking
    7. }

    Counting 429 and 5xx separately is critical: the former is a capacity and quota problem, solved with backoff and quota increases; only the latter is a signal that calls for circuit breaking and failover.

    3. Controlling Blast Radius: From Single Points to Layered Redundancy

    The lesson from long outages is simple: do not stake business availability entirely on a single upstream. Practical layered strategies include:

    1. Multi-provider and multi-model routing. Abstract a unified model invocation layer, encapsulate differences in authentication, parameters, and streaming protocols inside adapters, and split traffic by weight and real-time health.
    2. Circuit breaking and degradation. Consecutive failures open the circuit; degrade to a smaller model, cached results, or rule-based replies so the main path stays “slow but available.”
    3. Request tiering. Classify tasks into online interaction, near-real-time batch, and offline batch; during failures, protect online interaction first and defer or replay batch jobs.
    4. Idempotency and replayability. Generate a business idempotency key for each request, buffer with a message queue, and compensate automatically after recovery to avoid duplicate billing and duplicate writes.
    1. {
    2. "route": {"primary": "model-a", "fallback": "model-b", "weight": [0.8, 0.2]},
    3. "circuit": {"error_threshold": 0.2, "window_sec": 60, "open_sec": 30},
    4. "timeout": {"first_byte_ms": 3000, "total_ms": 60000}
    5. }

    4. Doing Retries and Timeouts Right

    LLM endpoints differ from ordinary RPC: output is generated incrementally, so naive retries cause duplicate charges and a jittery experience. The recommended approach is to retry only failures that produced no valid output, using exponential backoff with jitter and an overall time cap. For interruptions after streaming has already begun, prefer continuing the answer or prompting the user to resend rather than silently starting over.

    1. import random, time
    2. def call_with_retry(fn, max_try=3, base=0.5, cap=8.0):
    3. for i in range(max_try):
    4. try:
    5. return fn()
    6. except RetryableError:
    7. if i == max_try - 1:
    8. raise
    9. time.sleep(min(cap, base * (2 ** i)) + random.random() * 0.2)

    5. Interface Governance After Opening Up Capabilities

    When capabilities such as deep thinking, web search, file input, speech, and underlying recognition and synthesis are exposed as parameter switches or separate endpoints, architectural complexity rises sharply. Three governance points matter:

    • Capability orchestration. Define “retrieval-reasoning-generation-speech playback” as an orchestrable flow where each step has its own timeout and failure policy, so one weak link does not drag down the whole chain.
    • Input governance. Files and long contexts bring parsing and truncation problems, so the gateway should handle format validation, size limits, and sensitive-data handling uniformly.
    • Cost observability. Tag and meter tokens and call counts by capability, and set tenant-level quotas and alerts to prevent abnormal loops from inflating the bill.

    6. Observability and Drill Mechanisms

    Without observability there is no availability. Collect four kinds of data: call traces, error-code distribution, upstream health, and business success rate. Configure multi-level alerts with a clear on-call response. Run a failure drill every quarter: simulate upstream 5xx, rate limiting, and long-tail latency to verify that circuit-breaker thresholds, degradation paths, and compensation jobs actually work. Also keep status-page subscriptions and multi-channel notifications so external incidents feed into your own incident response.

    7. Conclusion

    The essence of availability is engineering uncertainty: measure it with the right metrics, control blast radius with redundancy and degradation, guarantee consistency with retries and idempotency, and validate plans with drills. If you need managed model services along with supporting object storage, message queues, container platforms, log services, and monitoring and alerting, Baidu AI Cloud can provide general cloud infrastructure to help teams turn stability goals into an executable architecture.