On Fri, Apr 3, 2020 at 5:21 AM Igor Cicimov <ig...@encompasscorporation.com> wrote:
> Hi all, > > Probably another quite basic question that I can't find an example of in > the docs (at least as a warning not to do that as it does not make sense or > bad practise) or on the net. It is regarding the usage of multiple balance > statements in a backend like this: > > balance leastconn > balance hdr(Authorization) > > So basically is this a valid use case where we can expect both options to > get considered when load balancing or one is ignored as a duplicate (in > which case which one)? > > And in general how are duplicate statements being handled in the code, > .i.e. the first one or the last one is considered as valid, and are there > maybe any special statements that are exempt from the rule (like hopefully > balance :-) ) > > Thanks in advance. > > Igor > > Hi Igor, duplicate statement processing depends on the keyword: very few are cumulative, and most of them s "last found match". To come back to the original point, you already a chance to have 2 LB algorithm: if you do 'balance hdr(Authorization)' and no Authorization header can be found, then HAProxy fails back to a round robin mode. Now, if you need persistence, I think you can enable "balance leastconn" and then use a stick table to route known Authorization header to the right server. More information here: https://www.haproxy.com/fr/blog/load-balancing-affinity-persistence-sticky-sessions-what-you-need-to-know/ Baptiste