From: Aurelien DARRAGON Date: Mon, 16 Feb 2026 15:12:15 +0000 (+0100) Subject: MEDIUM: backend: make "balance random" consider tg local req rate when loads are... X-Git-Tag: v3.4-dev5~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=747ff09818996bdc3667ceb8d2a11c367095e869;p=thirdparty%2Fhaproxy.git MEDIUM: backend: make "balance random" consider tg local req rate when loads are equal This is a follow up to b6bdb2553 ("MEDIUM: backend: make "balance random" consider req rate when loads are equal") In the above patch, we used the global sess_per_sec metric to choose which server we should be using. But the original intent was to use the per thread group statistic. No backport needed, the previous patch already improved the situation in 3.3, so let's not take the risk of breaking that. --- diff --git a/src/backend.c b/src/backend.c index b531843fc..abe3942d3 100644 --- a/src/backend.c +++ b/src/backend.c @@ -585,8 +585,8 @@ struct server *get_server_rnd(struct stream *s, const struct server *avoid) curr = prev; else if (wcurr == wprev && curr->counters.shared.tg && prev->counters.shared.tg) { /* same load: pick the lowest weighted request rate */ - wcurr = read_freq_ctr_period_estimate(&curr->counters._sess_per_sec, MS_TO_TICKS(1000)); - wprev = read_freq_ctr_period_estimate(&prev->counters._sess_per_sec, MS_TO_TICKS(1000)); + wcurr = read_freq_ctr_period_estimate(&curr->counters.shared.tg[tgid - 1]->sess_per_sec, MS_TO_TICKS(1000)); + wprev = read_freq_ctr_period_estimate(&prev->counters.shared.tg[tgid - 1]->sess_per_sec, MS_TO_TICKS(1000)); if (wprev * curr->cur_eweight < wcurr * prev->cur_eweight) curr = prev; }