Skip to main content

Module load_balancing

Module load_balancing 

Source

Structs§

Candidates
The candidates of one selection: a borrowed view of a cluster’s backend list, restricted to the positions a caller retained.
LeastLoaded
The least loaded candidate, load measured per unit of weight.
Maglev
Maglev consistent hashing (Google, NSDI’16).
PowerOfTwo
Power-of-two-choices (P2C) load-aware selection: sample two candidates, keep the lighter one, and coin-flip a tie.
Random
Uniform (optionally weight-biased) random backend selection.
Rendezvous
Weighted Rendezvous (Highest Random Weight) hashing.
RoundRobin
Round-robin selection, weighted by weight through smooth weighted round robin (the nginx ngx_http_upstream_get_peer scheme).
ShuffleSharding
A cluster’s shuffle-sharding policy (sozu-proxy/sozu#524).

Constants§

DEFAULT_HASH_SEED
Fixed seed used by the affinity hashers (HRW / Maglev). It must NOT be a RandomState: the selection has to be reproducible across workers and across process restarts so that every Sōzu instance routing the same flow key lands on the same backend. The constant is arbitrary but stable.

Traits§

LoadBalancingAlgorithm

Functions§

affinity_key_from_ip
The affinity key Rendezvous and Maglev pin a client with, derived from its source address.
affinity_key_from_value
The affinity key derived from the bytes of a request header or cookie value, for a cluster that keys its clients on one.
hrw_score
The weighted rendezvous (HRW) score of backend for the affinity key, under DEFAULT_HASH_SEED: the score Rendezvous ranks a cluster’s backends by. Larger is better. Shuffle sharding (ShuffleSharding) takes a client’s shard as the top of this ranking, and a test that needs to predict a shard computes it with this function.