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.
This commit is contained in:
Aurelien DARRAGON 2026-02-16 16:12:15 +01:00
parent 1274c21a42
commit 747ff09818

View File

@ -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;
}