Expand description
Load balancer for backend selection
This module handles backend selection (service -> specific backend addr).
The ServiceRegistry handles routing
(host+path -> service). These are separate concerns.
§Strategies
LbStrategy::RoundRobin— Cycles through healthy backends in order.LbStrategy::LeastConnections— Picks the healthy backend with the fewest active connections (tracked via atomic counters).
§Health checking
LoadBalancer::spawn_health_checker launches a background task that
periodically TCP-connects to every backend across all groups, updating
health status atomically. Concurrency is bounded by a semaphore.
Structs§
- Backend
- Per-backend state with atomic connection counting and health tracking.
- Backend
Group - A set of backends for a single service, with a configured selection strategy.
- Backend
Group Snapshot - Point-in-time snapshot of a backend group’s state.
- Backend
Snapshot - Point-in-time snapshot of a single backend’s state.
- Connection
Guard - RAII guard that decrements a backend’s active connection count on drop.
- Load
Balancer - Top-level load balancer that manages backend groups keyed by service name.
Enums§
- Health
Status - Whether a backend is considered reachable.
- LbStrategy
- Load-balancing strategy for a backend group.