How to Keep Core Business Running During Partial LLM API Outages

    When third-party LLM APIs suffer occasional partial outages, applications are often dragged down with them. This article breaks down the root causes of peak-hour failures and covers four practical approaches: circuit breakers with graceful degradation, multi-model routing, asynchronous queues, and independent monitoring. It includes a runnable circuit breaker example, a routing decision table, and a go-live checklist to help developers protect core functionality when platforms become unstable.

    Retries and jitter. When a platform slows down, uncontrolled retries on your side multiply the pressure. Backoff should grow exponentially with random jitter added, so that large numbers of requests don’t retry at the same moment. You should also set a retry budget—for example, retries within a window should not exceed 10% of total requests—and degrade directly once the budget is exhausted. When you receive a 429, prioritize waiting for the duration specified in the platform’s Retry-After header.

    The following code includes a retry function with jitter, plus a bulkhead that isolates concurrency per route. The bulkhead limits how many concurrent calls a single route can occupy, so when one route slows down, it won’t exhaust the connections and threads of other routes.

    1. import random
    2. import threading
    3. import time
    4. def retry_with_jitter(fn, max_attempts=3, base=0.5, cap=8.0):
    5. """Retry only on timeout; each wait is randomized between 0 and the exponential cap."""
    6. for attempt in range(max_attempts):
    7. try:
    8. return fn()
    9. except TimeoutError:
    10. if attempt == max_attempts - 1:
    11. raise
    12. time.sleep(random.uniform(0, min(cap, base * 2 ** attempt)))
    13. class Bulkhead:
    14. """Limit concurrency per route; reject immediately when full."""
    15. def __init__(self, max_concurrent):
    16. self.sem = threading.BoundedSemaphore(max_concurrent)
    17. def call(self, fn, *args, **kwargs):
    18. if not self.sem.acquire(blocking=False):
    19. raise RuntimeError("Bulkhead full, degrade immediately")
    20. try:
    21. return fn(*args, **kwargs)
    22. finally:
    23. self.sem.release()

    Circuit breaker false positives usually come from four sources: a sliding window that is too short, too few samples, timeouts set so short that slow requests are treated as failures, and counting content moderation rejections as failures. The fix is to count only timeouts, 5xx errors, and connection errors toward the circuit breaker, and handle other errors separately. Thresholds should be validated through load testing with the real latency distribution. Every state transition of the circuit breaker should be logged to make post-incident reviews easier.

    Independent monitoring. Monitoring should not rely solely on the platform’s own status page, nor share the same path as your business traffic. The monitoring system should be deployed outside the business, and alerts should not depend on the platform being monitored. Concretely:

    • Probe each route every minute with a small request, recording success rate, time to first byte, and the proportion of 429 responses.
    • Alert thresholds can start from these values: a route’s error rate exceeds 5% for three consecutive minutes, or P95 time to first byte exceeds 5 seconds.
    • Push alerts when the circuit breaker opens, enters half-open state, closes again, or when a fallback route is activated.
    • Probe requests incur costs, so control their frequency and payload, and never include sensitive user data in them.

    5. Go-Live Checklist

    Confirm each item before launch, with a clear owner and verification method for every one.

    • Switches: each route and each degradation level can be enabled or disabled independently, without redeploying.
    • Thresholds: sliding window size, minimum sample count, error rate threshold, and timeout values are all validated through load testing and recorded in configuration.
    • Alerts: circuit breaker openings, fallback route activation, queue backlog, and rising 429 rates all have corresponding alerts, and the notification channels are working.
    • Drills: simulate three scenarios—the platform returning 500 continuously, continuous timeouts, and continuous rate limiting—and confirm each degradation path works as expected.
    • Rollback: when anomalies occur, you can disable new routes or circuit breaker rules within minutes and restore the original call path.
    • Load testing: under peak traffic, total retries stay within budget, and requests rejected by the bulkhead all reach the degradation branch.

    Protect the core path first, then degrade in layers by error type. Non-core features can be processed later or switched off entirely, leaving limited quota and concurrency for the core business.