On Fri, May 12, 2017 at 02:00:24PM -0700, redundantl y wrote:
> Is it possible to configure a secondary load balancing method, something to
> fall back on if the first method isn't met?
> 
> For example, if I balance on the url_param email:
> 
>     balance url_param email
> 
> Can it instead balance on another url_param:
> 
>     balance url_param id
> 
> Or have it balance based on source address?
> 
> I tried setting the following:
> 
>     balance url_param email
>     balance url_param id
> 
> But it only balanced on the second one, id.
> 
> I haven't found anything saying this is possible, but I'd just like to make
> sure it isn't.

You can't do this, and there is already a fallback on algorithms involving
hashes, but the fallback is to round robin, as indicated in the doc. What
you can do however is to check in your frontend if you have this parameter
and use a specific backend when it is present, or another one when it is
not present. Eg:

  frontend blah
         use_backend lb-email if { url_param(email) -m found }
         use_backend lb-id if { url_param(id) -m found }
         default_backend lb-src

  backend lb-email
         balance url_param email
         server s1 1.1.1.1 track lb-src/s1
         server s2 1.1.1.2 track lb-src/s2

  backend lb-id
         balance url_param id
         server s1 1.1.1.1 track lb-src/s1
         server s2 1.1.1.2 track lb-src/s2

  backend lb-src
         balance src
         server s1 1.1.1.1 check
         server s2 1.1.1.2 check

Willy

Reply via email to