Sticky Load Balancing with Varnish - sick backends

Soesoe dev at soeren-soerries.de
Thu Jan 20 14:51:02 CET 2011


Hello everybody,

we tried to enable "Sticky Load Balancing" with varnish 2.0.6 like this
thread:
http://www.varnish-cache.org/lists/pipermail/varnish-misc/2010-April/004111.html

But changed a custom cookie to the JSESSION Cookie from Tomcat and select
the right backend via the jvmrout of the session:
works fine - if the selected backend doesn't go sick.

if the selected backend gos sick, varnish tries to choose still the sick
backend
or sends an error 503 -

we tried to catch this error and "restart" by setting a roundrobin director
but still the redirect to our error page happens, and not to one of the
other healthy backends?

to you have any hints for me?
Thanks Soeren

this is our config (in parts)
-----------------------------------------------------------------------------------------------------------------------------

sub recv_loadBalancingOnStickyCookie {
    if (req.http.Cookie ~ "JSESSIONID=") {
        set req.http.StickyVarnish = regsub( req.http.Cookie,
"^.*?JSESSIONID=([^;]*);*.*$","\1" );
        call chooseBackend;
        unset req.http.StickyVarnish;
    } else {
        call chooseBackend;
    }
}

sub chooseBackend {
    if (req.http.StickyVarnish ~ "back01a$") {
        set req.backend = back01a;
    } else
    if (req.http.StickyVarnish ~ "back01b$") {
        set req.backend = back01b;
    } else
    if (req.http.StickyVarnish ~ "back02a$") {
        set req.backend = back02a;
    } else
    if (req.http.StickyVarnish ~ "back02b$") {
        set req.backend = back02b;
    } else
{
##default
set req.backend = wwwround;
}
}

sub vcl_error{

if (obj.status == 404) {
    set obj.http.Location = "
http://server.de/404/index.html?WT.mc_id=varnish_error404";
    set obj.status = 302;
}

if (obj.status == 503 && req.restarts < 4) {
set req.backend = wwwround;
    restart;
        } else if (obj.status == 503 && req.restarts >= 4)
 {
    set obj.http.Location = "
http://server.de/500/index.html?WT.mc_id=varnish_error503";
    set obj.status = 302;
}

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110120/362ac0ab/attachment-0003.html>


More information about the varnish-misc mailing list