Hello fellow Haproxy users.

Here are some thoughts and example ideas about backend definitions and
seeing if anyone has thought of these features or if they're even
possible today.


Cheers,

Joel Krauska



1. 'Stats only backend'
I'd like to keep stats for a certain matching condition, but don't
want to define the same backend twice.

eg.
use_backend one if { hdr_dom(host) -i one  }
use_backend two if { hdr_dom(host) -i two  }

backend one
        cookie SID insert indirect
        server app-01:8080 app-01:8080 cookie app1-8080 check inter 3s
rise 2 fall 2 maxconn 255
        server app-02:8080 app-02:8080 cookie app2-8080 check inter 3s
rise 2 fall 2 maxconn 255
        option httpchk GET /healthcheck.html
        stats admin if TRUE

backend two
        # MADE UP COMMAND IS HERE
        use_backend one

Not sure if stats for one should == stats for one + stats for two, or
if it would be better for hits to two to only count on two...
I think my preference would be that stats would only count against backend two.
Obviously you need to be careful not to allow for backend looping.


2. 'backend with backup backend'
Fall through to a different backend if primary servers are unavailable
(similar to backup server -- but not requiring defining groups twice
if there's some overlap in pool definitions)

use_backend one if { hdr_dom(host) -i one  }
use_backend two if { hdr_dom(host) -i two  }

backend one
        cookie SID insert indirect
        server app-01:8080 app-01:8080 cookie app1-8080 check inter 3s
rise 2 fall 2 maxconn 255
        server app-02:8080 app-02:8080 cookie app2-8080 check inter 3s
rise 2 fall 2 maxconn 255
        option httpchk GET /healthcheck.html
        stats admin if TRUE

backend two
        server app-03:8080 app-03:8080 cookie app1-8080 check inter 3s
rise 2 fall 2 maxconn 255
        server app-04:8080 app-04:8080 cookie app2-8080 check inter 3s
rise 2 fall 2 maxconn 255
        # MADE UP COMMAND IS HERE
        backup_backend one


3. 'backend macro includes'
Similar in concept to #1, but maybe more flexible.

use_backend one if { hdr_dom(host) -i one  }
use_backend two if { hdr_dom(host) -i two  }

backend_macro macro-one
        cookie SID insert indirect
        server app-01:8080 app-01:8080 cookie app1-8080 check inter 3s
rise 2 fall 2 maxconn 255
        server app-02:8080 app-02:8080 cookie app2-8080 check inter 3s
rise 2 fall 2 maxconn 255
        option httpchk GET /healthcheck.html
        stats admin if TRUE

backend one
        # MADE UP COMMAND IS HERE
        include_backend_macro macro-one

backend two
        # MADE UP COMMAND IS HERE
        include_backend_macro macro-one

Reply via email to