Skip to main content
Looking for comprehensive provider routing documentation?For a detailed guide covering how adaptive load balancing works with governance routing, the two-level architecture (provider + key selection), Model Catalog integration, and example scenarios, see the Provider Routing Guide.This page focuses on the technical implementation and performance characteristics of adaptive load balancing.

Overview

Adaptive Load Balancing Dashboard
Adaptive Load Balancing in Bifrost Enterprise automatically optimizes traffic distribution across providers and keys based on real-time performance metrics. The system operates at two levels - provider selection (direction) and key selection (route) - continuously monitoring error rates, latency, and throughput to dynamically adjust weights, ensuring optimal performance and reliability.
Zero-overhead design: All route selection logic adds less than 10 microseconds to hot path latency. Weight calculations happen asynchronously every 5 seconds, so request routing uses pre-computed weights with minimal overhead.

Architecture

The load balancing system operates at two levels:
  • Direction-level (provider + model): Decides which provider to use for a given model
  • Route-level (provider + model + key): Decides which API key to use within a provider
This two-tier approach enables both macro-level provider selection and micro-level key optimization.

How Weight Calculation Works

Every 5 seconds, the system recalculates a weight for each route from its recent performance. Three signals drive the score, in priority order: Which signals apply depends on the route’s health: healthy routes are scored mainly on errors and latency, while routes that are actively recovering are scored on latency and recovery progress so they aren’t held back by stale error history. The combined score maps to a weight on a fixed scale - lower penalties mean higher weight, which means more traffic - with a floor so no route is ever fully starved while it has a chance to recover.

Key Capabilities

  1. Automatic Route Health Management: Routes automatically transition between 4 states (Healthy, Degraded, Failed, Recovering) based on error rates and latency. No manual intervention required when a route fails or recovers.
  2. Fair Traffic Distribution: The system prevents any single route from being overloaded while still favoring better performers. Low-weight routes always get minimum traffic to prove recovery.
  3. Real-time Dashboard: Provides visibility into weight distribution, performance metrics (error rates, latency), state transitions, and actual vs expected traffic per route.
Adaptive Load Balancing Dashboard
  1. Multi-Factor Scoring: Routes are scored from error rate (the primary, time-decayed signal), a token-aware latency score (comparing a route both to its peers and to its own recent baseline), and fair-share utilization. Recovering routes are scored to favor quick, safe recovery.
  2. Smart Key Selection: Traffic is distributed probabilistically - higher-weight keys get proportionally more requests, but lower-weight keys keep a small share so potentially-recovered routes are continually re-probed instead of always picking the single best route.
  3. Performance Thresholds: Pre-tuned error-rate and latency triggers drive state transitions - a route is marked Degraded at the first signs of trouble, Failed on sustained errors or a rate-limit hit, and promoted back to Healthy only after it has proven itself on live traffic.
The system is designed to be self-healing: it penalizes failing routes quickly, but also decays those penalties rapidly once issues are fixed, so a recovered route returns to full traffic within seconds.

Configuration

Adaptive load balancing ships pre-tuned - the scoring weights, thresholds, and recovery timings are not user-configurable by design. The operator controls are four switches: The two selection switches default on; the two failed-direction behaviors are opt-in. All four take effect live (no restart) and propagate across the cluster. All four switches can be changed from the dashboard, via the API, or in config.json.
The load balancer settings page exposes the four switches; changes apply immediately across the cluster.
Load Balancer Settings

Scope & Limitations

  • Per-node weights: Each node load-balances on its own observed metrics. The only signal shared across nodes is a rate-limit (TPM) backoff, and only within the same region - there is no global weight consensus or cross-region coordination. This is deliberate: latency and error profiles differ per region, so importing another region’s metrics would pollute a node’s view of route health.
  • ~5-second adaptation: Weight and state changes lag live traffic by up to one recompute cycle. Immediate per-request resilience (key rotation and fallback failover) is handled separately and is not subject to this delay.
  • Optimistic cold start: A brand-new key or provider enters at full weight and competes at roughly fair share before it has been measured, then self-corrects within a cycle or two.
  • Relative, not absolute: Routes are ranked against their peers, not against a fixed latency or cost target. The system is not cost-, org-, or session-aware, and does not accept manual per-key weights for the adaptive path - those concerns are handled by governance routing.

Next Steps

  • Provider Routing - How adaptive load balancing composes with governance rules and the Model Catalog
  • Circuit Breaker - Header-signal-driven failover to a backup provider when a primary endpoint degrades
  • Clustering - Multi-node deployments and the gossip layer behind cross-node load balancer signals