Why Do Transient Online Failures Keep Happening? AI Service Stability Governance in Practice

    As more teams integrate external large language model APIs into daily workflows, service stability becomes a business risk rather than just an infrastructure concern. This article explains how to measure AI service availability with real request data, MTBF, and MTTR; how to classify failures and assess their impact; why peak-hour outages cause disproportionate damage; and how to design client-side fault tolerance, server-side monitoring and alerting, structured postmortems, and a practical stability checklist.

    1. The Core Problem: Business Risk When Depending on External Services

    More and more teams are integrating large model capabilities into daily workflows. Document summarization, coding assistance, data analysis, customer support responses, internal retrieval, and similar scenarios all call external model APIs directly. This model is highly efficient, but it also transfers risk: once the model service becomes abnormal, the business side cannot directly fix the underlying problem. It can only wait for the service provider to recover while absorbing downtime, delays, and user complaints.

    Stability problems are amplified for two main reasons. First, AI service call chains are long, typically including gateways, authentication, queueing, inference clusters, streaming transmission, and result write-back. A bottleneck in any one link can manifest as slow responses or failed requests. Second, usage peaks overlap heavily with business peaks. Researching and writing proposals on weekday afternoons, and rushing to write code in the evening, are exactly the periods with the highest API call volumes. For the same one-hour outage, the actual business impact during a low-traffic period and a peak period can differ several times over.

    Therefore, when evaluating the stability of an external AI service, it is not enough to ask whether it recovered. You also need to ask when the failure occurred, how long it lasted, and which links were affected. Only by discussing these dimensions within the same framework can you judge whether the service truly meets production requirements.

    2. Measuring Stability with Availability

    Availability is the most commonly used metric for measuring service stability. Its basic definition is:

    Availability = normal service duration in the measurement period ÷ total duration of the measurement period

    Note that availability should usually be calculated from real requests, not only from health check results. Health checks can show whether a service process is alive, but they cannot reflect request success rates, latency distribution, or whether some functionality is impaired. A common industry practice is to use request success rate, timeout rate, and latency percentiles as the main basis, combined with classification of server-side error codes.

    2.1 The Relationship Between Failure Frequency and Recovery Speed

    Availability is determined by two factors: how often failures occur, and how quickly each failure is recovered. This can be described using mean time between failures (MTBF) and mean time to recovery (MTTR):

    Availability ≈ MTBF ÷ (MTBF + MTTR)

    Suppose a service experiences a failure once every 6 hours on average, so MTBF is 360 minutes; each recovery takes 13 minutes, so MTTR is 13 minutes. Substituting into the formula:

    360 ÷ (360 + 13) ≈ 96.5%

    This result shows that even if recovery is fast, overall availability remains low as long as failures are frequent enough. Conversely, if the failure interval is extended to more than one week, availability will improve significantly even with the same MTTR. Therefore, recovery speed is an important metric, but it cannot replace failure prevention and governance of failure frequency.

    2.2 Converting Availability into Cumulative Unavailable Time

    Management and business stakeholders find it easier to understand “how long the service was cumulatively unavailable.” Using a 30-day period, common availability levels correspond to the following unavailable durations:

    Availability Cumulative unavailable time over 30 days Typical perception
    99.9% About 43 minutes Occasional brief jitter, largely unnoticeable
    99.5% About 3.6 hours A few batch jobs need to be rerun
    96% About 28.8 hours Daily work is frequently blocked and requires manual fallback

    As the table shows, when availability drops from 99.9% to 96%, it looks like a difference of just over three percentage points, but cumulative unavailable time increases by more than 30 times. For businesses that depend on external services, this gap is enough to change the way work is done.

    3. Failure Classification and Impact Assessment

    Not every anomaly means “completely unavailable.” In real operations, failures usually take multiple forms, and they should be defined and monitored separately.

    • Full unavailability: APIs generally return connection failures or gateway errors, and all dependent parties are interrupted at the same time.
    • Partial functional degradation: Some models or some endpoints are abnormal while other functions remain normal. This type of problem is the easiest to overlook because overall metrics may still look acceptable.
    • Elevated latency: Requests can return successfully, but time to first byte or complete response time becomes noticeably longer, causing client timeouts.
    • Increased error rate: The failure rate rises for specific types of requests, such as long-context requests or streaming output requests.
    • Authentication and login anomalies: Session expiry, verification code delivery failures, or token refresh anomalies can block users from entering the system.

    When assessing impact, it is advisable to record three types of information at the same time: affected functional modules, the proportion of affected users, and the affected time window. The time window is especially critical. For the same one-hour outage, if it happens to fall during a business peak, its business cost should be weighted more heavily in risk assessment.

    4. Risk Amplification Mechanisms During Business Peaks

    Failures during peak periods are more harmful for three main reasons.

    First, queue backlog. Requests flood in during peak periods, and after the server recovers it needs to drain the backlog. This can cause secondary congestion within a short period, and high latency may persist for some time even after recovery.

    Second, retry storms. Clients retry immediately after a request fails. A large number of requests retrying at the same time further increases the load on the server and prolongs recovery. This phenomenon is especially common in systems without backoff mechanisms.

    Third, the cost of manual waiting. When users face an interruption, they often have no choice but to stop their work and wait. For an individual, a one-hour interruption is a loss of productivity; for a team, it may mean collective stagnation of multiple people working in parallel.

    The main engineering responses to these mechanisms are: implement exponential backoff with jitter on the client side, set rate limits and queue caps on the server side, and prepare fallback paths for critical business flows. These are discussed separately below.

    5. Client-Side Fault Tolerance Design

    The client side is the layer most easily overlooked, yet it can reduce the impact of failures most quickly. The following implements three common patterns: exponential backoff retry with jitter, a simple circuit breaker, and primary/fallback routing degradation. The code uses a generic interface and can be replaced with any external model call function.

    1. import random
    2. import time
    3. def call_with_retry(send, max_retries=3, base_delay=0.5, max_delay=8.0):
    4. """Exponential backoff retry with full jitter. Retry only retryable exceptions."""
    5. for attempt in range(max_retries + 1):
    6. try:
    7. return send()
    8. except (TimeoutError, ConnectionError):
    9. if attempt == max_retries:
    10. raise
    11. backoff = min(max_delay, base_delay * (2 ** attempt))
    12. time.sleep(random.uniform(0, backoff))
    13. class CircuitBreaker:
    14. """Pause calls after consecutive failures hit threshold; allow probe after timeout."""
    15. def __init__(self, failure_threshold=5, reset_timeout=30.0):
    16. self.failure_threshold = failure_threshold
    17. self.reset_timeout = reset_timeout
    18. self.failures = 0
    19. self.opened_at = None
    20. def allow(self):
    21. if self.opened_at is None:
    22. return True
    23. # After the circuit opens, allow one probe request after cooldown (half-open state)
    24. return time.monotonic() - self.opened_at >= self.reset_timeout
    25. def record_success(self):
    26. self.failures = 0
    27. self.opened_at = None
    28. def record_failure(self):
    29. self.failures += 1
    30. if self.failures >= self.failure_threshold:
    31. self.opened_at = time.monotonic()
    32. def generate(prompt, primary, fallback, breaker):
    33. """Prefer primary; fall back to backup when primary unavailable."""
    34. if breaker.allow():
    35. try:
    36. result = call_with_retry(lambda: primary(prompt))
    37. breaker.record_success()
    38. return result
    39. except Exception:
    40. breaker.record_failure()
    41. return fallback(prompt)

    There are several points to note when using this code. First, enable retries only for requests that are idempotent or safe to retry. For example, if a generation request has already been billed or has produced side effects, confirm the retry semantics first. Second, timeout values should be set according to the actual response distribution of the business, not simply inherited from defaults. Third, the fallback plan must be verified in advance. For example, check whether the output quality of the backup model meets business requirements; otherwise, fallback merely transfers the failure into a quality problem.

    6. Server-Side Monitoring and Alerting Design

    Client-side fault tolerance addresses “how to keep running during a failure,” while monitoring addresses “how to detect failures as early as possible.” A practical monitoring system usually includes the following layers.

    • Availability metrics: request success rate by endpoint, by model, and by region.
    • Latency metrics: record P50, P95, and P99 latency to avoid averages masking long-tail problems.
    • Business metrics: completion rates of critical business flows, such as login success rate and document processing completion rate.
    • Dependency health: record call results for external dependencies separately to distinguish internal failures from dependency failures.

    Alert rules should consider both intensity and duration to avoid alert fatigue caused by transient jitter. An example configuration approach is as follows:

    1. alerts:
    2. - name: model_request_error_rate_high
    3. metric: request_error_rate
    4. condition: value > 0.05
    5. duration: 3m
    6. severity: critical
    7. action: notify_oncall_and_enable_fallback
    8. - name: model_p95_latency_high
    9. metric: request_latency_p95_seconds
    10. condition: value > 10
    11. duration: 5m
    12. severity: warning
    13. action: notify_channel

    During peak periods, alert thresholds can be set by time of day. For example, the error rate threshold during working hours can be stricter because the same error rate has a greater impact during that period.

    7. A Structured Method for Incident Postmortems

    The purpose of an incident postmortem is to improve the system, not to assign personal blame. A complete postmortem report should include the following:

    1. Summary: incident time window, scope of impact, severity, and recovery time.
    2. Timeline: each key node from anomaly occurrence, alert triggering, and manual intervention to recovery.
    3. Impact assessment: affected features, request volume, number of users, and actual business losses.
    4. Root cause analysis: distinguish direct causes from underlying causes and state the sources of evidence.
    5. What went well: for example, whether alerts were timely and whether fallback took effect.
    6. Action items: each item should have an owner, a deadline, and a verification method.

    During postmortems, special attention should be paid to whether the incident recurs. If the same type of failure occurs multiple times within a month, it indicates that the problem has not been fundamentally resolved, and faster recovery cannot compensate for the reliability gap.

    8. Build Checklist

    When evaluating or building a system that depends on external AI services, you can check the following items one by one:

    • Is availability calculated from real requests and displayed separately by endpoint and function?
    • Are both MTBF and MTTR recorded, rather than focusing only on recovery speed?
    • Are peak-hour failures tracked separately, with adjusted alert and response priorities?
    • Does the client implement backoff retry with jitter and a circuit breaker?
    • Do critical business flows have validated fallback paths?
    • Is there a structured postmortem process that tracks the implementation of action items?
    • Are dependency outage scenarios tested regularly to confirm that fallback and alerts work under real pressure?

    Stability is not a one-time goal; it is an engineering capability that requires continuous investment. For teams that depend on external services, clearly quantifying risk, setting up layered defenses on both the client and server sides, and turning each failure into executable improvements are the reliable path to reducing the cost of business interruption.