Upstream Feedback#
Implements feedback-based load balancing for server groups of the Stream
Upstream module:
server weights are adjusted by a performance or health metric of each server.
The module's directive is set in the upstream block. Servers that accept connections faster get a higher score from the Default — upstream Enables a feedback-based load balancing mechanism for the The following parameters can be specified: The variable from which the feedback value is taken.
It should represent a performance or health metric;
it is assumed to be provided by the server. The value is evaluated with each response from the server
and factored into the moving average
according to If the parameter is set, the feedback value is interpreted inversely:
lower values indicate better performance. The factor by which the feedback value is weighted
when calculating the average.
Valid values are integers from 0 to 99.
Default is The average is calculated using the exponential smoothing formula. The larger the factor, the less new values affect the average;
if Specifies a condition variable
that controls how connections are accounted for in the calculation.
The average value is updated with the feedback value
only if the condition variable
is not equal to Note By default, traffic from probes
is not included in the calculation;
combining the $upstream_probe variable
with Example: This configuration categorizes servers by feedback levels
based on protocols used in individual sessions,
and also adds a condition on $upstream_probe
to account only for Configuration Example#
upstream backend {
zone backend 1m;
feedback $connect_score;
server backend1.example.com:1935;
server backend2.example.com:1935;
}
map $upstream_connect_time $connect_score {
~^0\.00 100;
~^0\.0 50;
default 10;
}
map
block and a larger share of sessions.Directives#
feedback (PRO)#
feedback variable [inverse] [factor=number] [account=condition_variable];upstream.
It dynamically adjusts load balancing decisions
by multiplying each proxied server's weight by the average feedback value,
which changes over time based on the variable value
and is subject to an optional condition.variableinverse and factor settings.inversefactor90.90 is specified, 90% of the previous value will be taken
and only 10% of the new value.account"" or "0".account allows including them
or even excluding everything else.upstream backend {
zone backend 1m;
feedback $feedback_value factor=80 account=$condition_value;
server backend1.example.com:1935 weight=1;
server backend2.example.com:1935 weight=2;
}
map $protocol $feedback_value {
"TCP" 100;
"UDP" 75;
default 10;
}
map $upstream_probe $condition_value {
"high_priority" "1";
"low_priority" "0";
default "1";
}
high_priority probes
or regular client sessions.