pub enum LoadBalancingAlgorithm {
Show 15 variants
RoundRobin,
LeastConnections,
Random,
IpHash,
Weighted,
ConsistentHash,
PowerOfTwoChoices,
Adaptive,
LeastTokensQueued,
Maglev,
LocalityAware,
PeakEwma,
DeterministicSubset,
WeightedLeastConnections,
Sticky,
}Expand description
Load balancing algorithm
Variants§
RoundRobin
LeastConnections
Random
IpHash
Weighted
ConsistentHash
PowerOfTwoChoices
Adaptive
LeastTokensQueued
Least tokens queued - for inference/LLM workloads
Selects the upstream with the fewest estimated tokens currently being processed. Useful for LLM inference backends where token throughput varies significantly between requests.
Maglev
Maglev consistent hashing - Google’s load balancing algorithm
Provides minimal disruption when backend servers are added/removed, with better load distribution than traditional consistent hashing. Uses a permutation-based lookup table for O(1) selection.
LocalityAware
Locality-aware load balancing
Prefers targets in the same zone/region as the proxy, falling back to other zones when local targets are unhealthy or overloaded. Useful for multi-region deployments to minimize latency.
PeakEwma
Peak EWMA (Exponentially Weighted Moving Average)
Twitter Finagle’s algorithm that tracks latency using EWMA and selects the backend with the lowest predicted completion time. Reacts quickly to latency spikes by using the peak of EWMA and recent latency.
DeterministicSubset
Deterministic Subsetting
For very large clusters (1000+ backends), limits each proxy instance to a deterministic subset of backends. Reduces connection overhead while ensuring even distribution across all proxies.
WeightedLeastConnections
Weighted Least Connections
Combines weight with connection counting. Selects the backend with the lowest ratio of active connections to weight. Useful when backends have different capacities.
Sticky
Cookie-based sticky sessions
Routes requests to the same backend based on an affinity cookie. Falls back to a configurable algorithm when no cookie is present or the target is unavailable. Useful for stateful applications that require session affinity.
Trait Implementations§
Source§impl Clone for LoadBalancingAlgorithm
impl Clone for LoadBalancingAlgorithm
Source§fn clone(&self) -> LoadBalancingAlgorithm
fn clone(&self) -> LoadBalancingAlgorithm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more