Smooth weighted round-robin balancing
4 days ago
- #upstream
- #round-robin
- #NGINX
- The code changes involve modifications to the round-robin peer selection algorithm in NGINX's upstream module.
- Key changes include the introduction of 'effective_weight' alongside 'current_weight' for peers.
- The 'ngx_http_upstream_get_peer' function has been refactored to return a peer pointer instead of an index.
- The peer selection logic now includes checks for peer failures and adjusts weights dynamically.
- The 'current_weight' of peers is now initialized to 0 instead of their weight.
- The algorithm now tracks tried peers using a bitmask to avoid reselection.
- The 'effective_weight' is adjusted based on peer failures and recovery.
- The changes aim to improve the reliability and efficiency of peer selection in load balancing.