Hadrian is experimental alpha software. Do not use in production.
Hadrian
ConfigurationFeatures

Load Balancing

Configure provider selection strategies and health checks

The [features.load_balancing] section configures how requests are distributed across providers when multiple providers support the same model.

Configuration Reference

Main Settings

[features.load_balancing]
strategy = "round_robin"
KeyTypeDefaultDescription
strategystring"round_robin"Load balancing strategy

Strategies

StrategyDescription
round_robinCycle through providers sequentially
least_connectionsRoute to provider with fewest active requests
randomRandom provider selection
weightedDistribute based on configured weights
latency_basedRoute to lowest-latency provider
cost_basedRoute to lowest-cost provider
# Round Robin (default)
[features.load_balancing]
strategy = "round_robin"

# Latency-based
[features.load_balancing]
strategy = "latency_based"

# Cost-based
[features.load_balancing]
strategy = "cost_based"

Health Checks

Configure provider health monitoring:

[features.load_balancing.health_check]
enabled = true
interval_secs = 30
unhealthy_threshold = 3
healthy_threshold = 2
KeyTypeDefaultDescription
enabledbooleantrueEnable health checks
interval_secsinteger30Check interval in seconds
unhealthy_thresholdinteger3Consecutive failures to mark unhealthy
healthy_thresholdinteger2Consecutive successes to mark healthy

Complete Examples

Round Robin with Health Checks

[features.load_balancing]
strategy = "round_robin"

[features.load_balancing.health_check]
enabled = true
interval_secs = 30
unhealthy_threshold = 3
healthy_threshold = 2

Latency-Based

[features.load_balancing]
strategy = "latency_based"

[features.load_balancing.health_check]
enabled = true
interval_secs = 15
unhealthy_threshold = 2
healthy_threshold = 1

Cost-Based

[features.load_balancing]
strategy = "cost_based"

[features.load_balancing.health_check]
enabled = true
interval_secs = 60
unhealthy_threshold = 5
healthy_threshold = 2

Disabled Health Checks

[features.load_balancing]
strategy = "random"

[features.load_balancing.health_check]
enabled = false

Strategy Selection

Use CaseRecommended Strategy
General workloadsround_robin
Latency-sensitivelatency_based
Cost optimizationcost_based
Variable loadleast_connections
Testing/debuggingrandom

Health Check Behavior

Provider A: ● ● ● ✗ ✗ ✗ → Unhealthy (3 consecutive failures)
Provider B: ● ● ● ● ● ● → Healthy
Provider C: ✗ ✗ ● ● ● ● → Healthy (2 consecutive successes)

Unhealthy providers are excluded from load balancing until they pass healthy_threshold consecutive checks.

See Also

On this page