feat(revolver): add model circuit breaker and zero-tolerance 503 fast-failover

- Implement ModelCircuitBreaker to track (provider, model) overload states independently of API keys
- Skip remaining keys in active tier immediately on 503 Service Unavailable / High Demand
- Protect key quotas by preventing 503 errors from marking keys as rate-limited
- Add 15s streaming TTFT timeout and reduce candidate timeout to 20s
- Add Model Circuit Breaker live telemetry and manual reset in Admin Console
- Add comprehensive automated test suite for circuit breaker and failover cascades
This commit is contained in:
tyuXX 2026-11-04 20:44:57 +00:00
parent ae0e04c65a
commit 4434d308d6
9 changed files with 931 additions and 72 deletions

View file

@ -24,8 +24,17 @@ RATE_LIMIT_DURATION_MS=60000
# ENABLE_NON_STREAMING_KEEPALIVE=true
# NON_STREAMING_KEEPALIVE_DELAY_MS=20000
# Candidate timeout per provider attempt before rotating (in ms)
# CANDIDATE_TIMEOUT_MS=60000
# Candidate timeout per provider attempt before rotating (in ms, default 20s)
# CANDIDATE_TIMEOUT_MS=20000
# Streaming Time-To-First-Token (TTFT) timeout before failover (in ms, default 15s)
# STREAM_FIRST_TOKEN_TIMEOUT_MS=15000
# Model circuit breaker cooldown duration on 503 / high demand (in ms, default 60s)
# MODEL_COOLDOWN_MS=60000
# Max consecutive timeouts per model target before tripping circuit breaker (default 0 when fallback tier exists)
# MAX_TARGET_TIMEOUT_RETRIES=0
# Cloudflare Tunnel configuration (for Docker deployment)
# Get your tunnel token from: https://dash.cloudflare.com/