mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 13:51:26 +02:00
MINOR: backend: move hash_balance_factor out of chash
This one is a proxy option which can be inherited from defaults even if the LB algo changes. Move it out of the lb_chash struct so that we don't need to keep anything separate between these structs. This will allow us to merge them into an union later. It even takes less room now as it fills a hole and removes another one.
This commit is contained in:
parent
a9a7249966
commit
76e84f5091
@ -144,6 +144,7 @@ struct lbprm {
|
|||||||
int tot_used; /* total number of servers used for LB */
|
int tot_used; /* total number of servers used for LB */
|
||||||
int wmult; /* ratio between user weight and effective weight */
|
int wmult; /* ratio between user weight and effective weight */
|
||||||
int wdiv; /* ratio between effective weight and user weight */
|
int wdiv; /* ratio between effective weight and user weight */
|
||||||
|
int hash_balance_factor; /* load balancing factor * 100, 0 if disabled */
|
||||||
char *arg_str; /* name of the URL parameter/header/cookie used for hashing */
|
char *arg_str; /* name of the URL parameter/header/cookie used for hashing */
|
||||||
int arg_len; /* strlen(arg_str), computed only once */
|
int arg_len; /* strlen(arg_str), computed only once */
|
||||||
int arg_opt1; /* extra option 1 for the LB algo (algo-specific) */
|
int arg_opt1; /* extra option 1 for the LB algo (algo-specific) */
|
||||||
|
@ -30,7 +30,6 @@ struct lb_chash {
|
|||||||
struct eb_root act; /* weighted chash entries of active servers */
|
struct eb_root act; /* weighted chash entries of active servers */
|
||||||
struct eb_root bck; /* weighted chash entries of backup servers */
|
struct eb_root bck; /* weighted chash entries of backup servers */
|
||||||
struct eb32_node *last; /* last node found in case of round robin (or NULL) */
|
struct eb32_node *last; /* last node found in case of round robin (or NULL) */
|
||||||
int balance_factor; /* load balancing factor * 100, 0 if disabled */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _TYPES_LB_CHASH_H */
|
#endif /* _TYPES_LB_CHASH_H */
|
||||||
|
@ -426,7 +426,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
|
|
||||||
if (curproxy->cap & PR_CAP_BE) {
|
if (curproxy->cap & PR_CAP_BE) {
|
||||||
curproxy->lbprm.algo = defproxy.lbprm.algo;
|
curproxy->lbprm.algo = defproxy.lbprm.algo;
|
||||||
curproxy->lbprm.chash.balance_factor = defproxy.lbprm.chash.balance_factor;
|
curproxy->lbprm.hash_balance_factor = defproxy.lbprm.hash_balance_factor;
|
||||||
curproxy->fullconn = defproxy.fullconn;
|
curproxy->fullconn = defproxy.fullconn;
|
||||||
curproxy->conn_retries = defproxy.conn_retries;
|
curproxy->conn_retries = defproxy.conn_retries;
|
||||||
curproxy->redispatch_after = defproxy.redispatch_after;
|
curproxy->redispatch_after = defproxy.redispatch_after;
|
||||||
@ -3654,8 +3654,8 @@ stats_error_parsing:
|
|||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
curproxy->lbprm.chash.balance_factor = atol(args[1]);
|
curproxy->lbprm.hash_balance_factor = atol(args[1]);
|
||||||
if (curproxy->lbprm.chash.balance_factor != 0 && curproxy->lbprm.chash.balance_factor <= 100) {
|
if (curproxy->lbprm.hash_balance_factor != 0 && curproxy->lbprm.hash_balance_factor <= 100) {
|
||||||
ha_alert("parsing [%s:%d] : '%s' must be 0 or greater than 100.\n", file, linenum, args[0]);
|
ha_alert("parsing [%s:%d] : '%s' must be 0 or greater than 100.\n", file, linenum, args[0]);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -453,7 +453,6 @@ void init_default_instance()
|
|||||||
defproxy.maxconn = cfg_maxpconn;
|
defproxy.maxconn = cfg_maxpconn;
|
||||||
defproxy.conn_retries = CONN_RETRIES;
|
defproxy.conn_retries = CONN_RETRIES;
|
||||||
defproxy.redispatch_after = 0;
|
defproxy.redispatch_after = 0;
|
||||||
defproxy.lbprm.chash.balance_factor = 0;
|
|
||||||
defproxy.options = PR_O_REUSE_SAFE;
|
defproxy.options = PR_O_REUSE_SAFE;
|
||||||
defproxy.max_out_conns = MAX_SRV_LIST;
|
defproxy.max_out_conns = MAX_SRV_LIST;
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ int chash_server_is_eligible(struct server *s)
|
|||||||
/* The total number of slots to allocate is the total number of outstanding requests
|
/* The total number of slots to allocate is the total number of outstanding requests
|
||||||
* (including the one we're about to make) times the load-balance-factor, rounded up.
|
* (including the one we're about to make) times the load-balance-factor, rounded up.
|
||||||
*/
|
*/
|
||||||
unsigned tot_slots = ((s->proxy->served + 1) * s->proxy->lbprm.chash.balance_factor + 99) / 100;
|
unsigned tot_slots = ((s->proxy->served + 1) * s->proxy->lbprm.hash_balance_factor + 99) / 100;
|
||||||
unsigned slots_per_weight = tot_slots / s->proxy->lbprm.tot_weight;
|
unsigned slots_per_weight = tot_slots / s->proxy->lbprm.tot_weight;
|
||||||
unsigned remainder = tot_slots % s->proxy->lbprm.tot_weight;
|
unsigned remainder = tot_slots % s->proxy->lbprm.tot_weight;
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ struct server *chash_get_server_hash(struct proxy *p, unsigned int hash, const s
|
|||||||
}
|
}
|
||||||
|
|
||||||
loop = 0;
|
loop = 0;
|
||||||
while (nsrv == avoid || (p->lbprm.chash.balance_factor && !chash_server_is_eligible(nsrv))) {
|
while (nsrv == avoid || (p->lbprm.hash_balance_factor && !chash_server_is_eligible(nsrv))) {
|
||||||
next = eb32_next(next);
|
next = eb32_next(next);
|
||||||
if (!next) {
|
if (!next) {
|
||||||
next = eb32_first(root);
|
next = eb32_first(root);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user