mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 12:41:00 +02:00
MINOR: log/balance: support for the "random" lb algorithm
In this patch we add basic support for the random algorithm: random algorithm picks a random server using the result of the statistical_prng() function as if it was a hash key to then compute the related server ID. There is no support for the <draw> parameter (which is implemented for tcp/http load-balancing), because we don't have the required metrics to evaluate server's load in log backends for the moment. Plus it would add more complexity to the __do_send_log_backend() function so we'll keep it this way for now but this might be needed in the future.
This commit is contained in:
parent
26f73dbcbb
commit
e0b4660015
@ -8839,6 +8839,12 @@ log-balance <algorithm> [ <arguments> ]
|
||||
goes back UP it is added at the end of the list so that the
|
||||
sticky server doesn't change until it becomes DOWN.
|
||||
|
||||
random A random number will be used as the key for the server
|
||||
lookup. Random log balancing can be useful with large farms
|
||||
or when servers are frequently added or removed from the
|
||||
pool of available servers as it may avoid the hammering
|
||||
effect that could result from roundrobin in this situation.
|
||||
|
||||
<arguments> is an optional list of arguments which may be needed by some
|
||||
algorithms.
|
||||
|
||||
|
||||
@ -2849,8 +2849,12 @@ int backend_parse_log_balance(const char **args, char **err, struct proxy *curpr
|
||||
/* we use ALGO_FAS as "sticky" mode in log-balance context */
|
||||
curproxy->lbprm.algo |= BE_LB_ALGO_FAS;
|
||||
}
|
||||
else if (strcmp(args[0], "random") == 0) {
|
||||
curproxy->lbprm.algo &= ~BE_LB_ALGO;
|
||||
curproxy->lbprm.algo |= BE_LB_ALGO_RND;
|
||||
}
|
||||
else {
|
||||
memprintf(err, "only supports 'roundrobin', 'sticky' options");
|
||||
memprintf(err, "only supports 'roundrobin', 'sticky', 'random', options");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user