DEV Community

LeoJulieta
LeoJulieta

Posted on

Build Multi‑Provider LLM Failover to Beat AI Outages

How to Survive the 2026 AI‑Outage Wave: Multi‑Provider Failover for ChatGPT, Claude & Gemini

Introduction

In March 2026 the AI world went dark: developers reported simultaneous “ChatGPT down”, “Claude unavailable”, and “Gemini offline” alerts across Hacker News, Reddit, and Twitter. Within hours Google Trends spiked for AI outage and LLM downtime, proving that enterprises can’t afford to wait for a single provider to recover.

This guide shows exactly what happened, why it happened, and—most importantly—how you can keep your applications running by building a resilient, multi‑provider failover stack with Docker and Kubernetes. You’ll get ready‑to‑run Python snippets for latency monitoring, a step‑by‑step deployment checklist, an SLA‑comparison table, and a quick FAQ.


What Went Wrong

Root cause How it impacted the three major services
Prompt‑hacking surge – a new wave of adversarial prompts that forced the models to generate extremely long token streams. All providers hit GPU memory limits, triggering throttling and request‑time‑outs.
Shared network fabric failure – a regional fiber‑cut in the East Coast ISP backbone that connects Azure, AWS, and GCP zones. Latency spiked > 2 seconds, causing autoscaling policies to over‑provision and then crash.
Mis‑configured autoscaling – aggressive scale‑out rules that launched dozens of GPU nodes per second without proper queue back‑pressure. GPU clusters saturated, leading to cascading restarts and a 30‑minute total outage for each service.

The combination of a traffic shockwave and a common network dependency turned isolated incidents into a synchronized blackout.


Quick FAQ

Question Answer
Why are multiple LLMs failing together? The three triggers above are common to all major providers; a single network incident can affect them simultaneously, and the prompt‑hacking surge stresses the same inference pipelines.
Can I switch providers without losing conversation context? Yes. Store the chat transcript and token metadata in a fast state store (Redis, DynamoDB, or Cosmos DB). When a failover occurs, replay the last n messages to the fallback model.
What SLA should I demand? Aim for ≥ 99.9 % uptime, ≤ 150 ms 99th‑percentile latency, explicit data‑residency clauses, and a force‑majeure carve‑out that excludes ISP‑level outages. See the comparison table in Section 5.

Building a Resilient Multi‑Provider Architecture

1. Overview Diagram (textual)

Client → Ingress (NGINX) → Failover Controller → 
   ├─ Primary: OpenAI (ChatGPT)  
   ├─ Secondary: Anthropic (Claude)  
   └─ Tertiary: Google (Gemini)  
State Store (Redis) ←→ Controller ←→ Metrics (Prometheus) → Alertmanager
Enter fullscreen mode Exit fullscreen mode

2. Docker‑Compose Skeleton (no fences)

version: "3.9"
services:
  ingress:
    image: nginx:stable
    ports: ["80:80"]
    volumes: ["./nginx.conf:/etc/nginx/nginx.conf"]
  failover:
    build: ./failover
    environment:
      - PRIMARY=OPENAI
      - SECONDARY=ANTHROPIC
      - THIRDARY=GOOGLE
    depends_on: [redis]
  redis:
    image: redis:7-alpine
    ports: ["6379:6379"]
Enter fullscreen mode Exit fullscreen mode

3. Kubernetes Manifests (key excerpts)

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: failover-controller
spec:
  replicas: 3
  selector:
    matchLabels:
      app: failover
  template:
    metadata:
      labels:
        app: failover
    spec:
      containers:
      - name: controller
        image: myrepo/failover:latest
        env:
        - name: PRIMARY
          value: "openai"
        - name: SECONDARY
          value: "anthropic"
        - name: THIRDARY
          value: "google"
        ports:
        - containerPort: 8080
Enter fullscreen mode Exit fullscreen mode

HorizontalPodAutoscaler

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: failover-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: failover-controller
  minReplicas: 2
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
Enter fullscreen mode Exit fullscreen mode

4. Python Helper for Latency Detection & Switchover (inline)

import time, requests, os
from redis import Redis

r = Redis(host="redis", port=6379, db=0)

PROVIDERS = {
    "openai":   "https://api.openai.com/v1/chat/completions",
    "anthropic":"https://api.anthropic.com/v1/messages",
    "google":   "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent"
}

def latency(url, token):
    start = time.time()
    try:
        requests.post(url, headers={"Authorization": f"Bearer {token}"}, json={"messages":[{"role":"user","content":"ping"}]}, timeout=5)
        return time.time() - start
    except Exception:
        return float("inf")

def select_provider():
    latencies = {name: latency(url, os.getenv(f"{name.upper()}_KEY")) for name, url in PROVIDERS.items()}
    best = min(latencies, key=latencies.get)
    r.set("active_provider", best)
    return best
Enter fullscreen mode Exit fullscreen mode

Schedule select_provider() every 30 seconds with a Kubernetes CronJob or a sidecar container. When latency exceeds 0.15 s, the script automatically promotes the next fastest provider.


SLA & Pricing Comparison (Q1 2026)

Vendor Uptime SLA 99th‑pct Latency SLA Free Tier Pay‑as‑you‑go (per 1 M tokens) Notable Clause
OpenAI 99.9 % ≤ 150 ms 5 M tokens/mo $0.0020 (prompt) / $0.020 (completion) Force‑majeure excludes ISP outages
Anthropic 99.9 % ≤ 150 ms 1 M tokens/mo $0.0015 / $0.015 Data‑residency guaranteed in US/EU
Google (Gemini) 99.95 % ≤ 120 ms 2 M tokens/mo $0.0018 / $0.018 Multi‑regional replication included

Use the table to negotiate contracts that explicitly cover shared‑network failures.


Compliance Checklist

  • Data Residency – Verify that the selected fallback provider stores logs in the same region as the primary.
  • Retention Policy – Set Redis TTL to ≤ 24 h for conversation snapshots.
  • Audit Logging – Enable CloudTrail (AWS), Activity Log (GCP), and Azure Monitor for every API call.
  • Security – Rotate API keys every 90 days; store them in a secret manager (HashiCorp Vault, AWS Secrets Manager).
  • Incident Reporting – Document failover events in a centralized ticketing system (Jira, ServiceNow) within 30 minutes of detection.

Step‑by‑Step Deployment Guide

  1. Provision a Kubernetes cluster (EKS, AKS, or GKE) with at least three zones in the same region.
  2. Create a Redis instance (managed or self‑hosted) and expose it to the cluster.
  3. Add API keys for OpenAI, Anthropic, and Google as Kubernetes Secrets.
  4. Deploy the failover-controller using the manifests above.
  5. Configure the Ingress to route all /chat traffic to the controller service.
  6. Set up Prometheus to scrape /metrics from the controller; create an Alertmanager rule that fires when latency > 150 ms for 2 minutes.
  7. Schedule the Python latency script as a CronJob (*/30 * * * *).
  8. Test the failover by manually blocking outbound traffic to one provider (e.g., iptables -A OUTPUT -d api.openai.com -j DROP) and confirming that requests are automatically redirected to the secondary.
  9. Run a load test (locust or k6) with a sustained 500 RPS to validate autoscaling

Herramienta mencionada: Groq Cloud

Top comments (0)