Multi-Region Active-Active AI Gateways on AWS us-east-1 & us-west-2: Zero-Downtime Failover With Cloudflare Workers and LiteLLM
Surviving Regional Cloud Degradation During Peak US Hours
In production US SaaS environments, relying on a single inference region (us-east-1) means any regional Bedrock/OpenAI gateway brownout or NAT failure drops customer-facing agents nationwide.
Deploying Active-Active Gateways behind a Cloudflare Workers edge router gives sub-50ms automatic regional failover between us-east-1 (Virginia) and us-west-2 (Oregon):
text[US East / West Clients] │ ▼ [Cloudflare Worker Edge Router (<15ms)] ├── Primary Pool: `us-east-1` LiteLLM + Bedrock/vLLM (Health OK) └── Failover Pool: `us-west-2` LiteLLM + Bedrock/vLLM (Auto-switch on 5xx / >2.5s TTFB)
Edge Failover Worker (worker.ts)
typescriptinterface Env { US_EAST_GATEWAY: string; US_WEST_GATEWAY: string; } export default { async fetch(request: Request, env: Env): Promise<Response> { const reqClone = request.clone(); const primaryUrl = `${env.US_EAST_GATEWAY}${new URL(request.url).pathname}`; const secondaryUrl = `${env.US_WEST_GATEWAY}${new URL(request.url).pathname}`; try { const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), 3000); // 3s TTFB guard const res = await fetch(primaryUrl, { method: request.method, headers: request.headers, body: request.body, signal: controller.signal, }); clearTimeout(timer); if (res.status < 500 && res.status !== 429) { return res; } } catch { // Primary timed out or unreachable -> fail over immediately to us-west-2 } return fetch(secondaryUrl, { method: reqClone.method, headers: reqClone.headers, body: reqClone.body, }); }, };
Key Takeaway
Cloning the request before the 3-second AbortController race lets your edge gateway reroute 429 rate-limit spikes and 503 regional brownouts to us-west-2 seamlessly without client retries.