pub struct Rendezvous { /* private fields */ }Expand description
Weighted Rendezvous (Highest Random Weight) hashing.
For an affinity key, the chosen backend is the one maximizing a stable,
per-(key, backend) score. With no key it degrades to plain round-robin;
every datapath supplies one for a client it can identify (the UDP affinity
key, and the client key of HTTP, HTTPS and TCP, sozu-proxy/sozu#524), so the
fallback is reached only for a request with no source address.
§Weighting
We use the standard continuous weighted-rendezvous score (Schindelhauer–Schomaker / “logarithmic method”):
score(key, backend) = -weight / ln(h)where h = hash64(seed, key, backend_addr) / 2^64 ∈ (0, 1). Because
ln(h) < 0, the score is positive and grows with weight, so heavier
backends win proportionally more keys while the choice stays deterministic
and minimally disruptive: removing a non-winning backend cannot change the
winner, and adding one only steals the keys for which it now scores highest.
Selection is O(N) per key.
Implementations§
Trait Implementations§
Source§impl Debug for Rendezvous
impl Debug for Rendezvous
Source§impl Default for Rendezvous
impl Default for Rendezvous
Source§impl LoadBalancingAlgorithm for Rendezvous
impl LoadBalancingAlgorithm for Rendezvous
Source§fn next_available_backend(
&mut self,
key: Option<u64>,
backends: Candidates<'_>,
) -> Option<Rc<RefCell<Backend>>>
fn next_available_backend( &mut self, key: Option<u64>, backends: Candidates<'_>, ) -> Option<Rc<RefCell<Backend>>>
candidates. Read moreSource§fn rebuild(&mut self, backends: &[Rc<RefCell<Backend>>])
fn rebuild(&mut self, backends: &[Rc<RefCell<Backend>>])
Maglev rebuilds
its table, and RoundRobin (with the round-robin fallback of
Rendezvous and Maglev) resets its running weights.