<div>Hello everybody,</div><div><br></div><div>we tried to enable "Sticky Load Balancing" with varnish 2.0.6 like this thread: <a href="http://www.varnish-cache.org/lists/pipermail/varnish-misc/2010-April/004111.html">http://www.varnish-cache.org/lists/pipermail/varnish-misc/2010-April/004111.html</a></div>
<div><br></div><div>But changed a custom cookie to the JSESSION Cookie from Tomcat and select the right backend via the jvmrout of the session:</div><div>works fine - if the selected backend doesn't go sick.</div><div>
<br></div><div>if the selected backend gos sick, varnish tries to choose still the sick backend</div><div>or sends an error 503 -</div><div><br></div><div>we tried to catch this error and "restart" by setting a roundrobin director</div>
<div>but still the redirect to our error page happens, and not to one of the other healthy backends?</div><div><br></div><div>to you have any hints for me?</div><div>Thanks Soeren</div><div><br></div><div>this is our config (in parts)</div>
<div>-----------------------------------------------------------------------------------------------------------------------------</div><div><br></div><div><div>sub recv_loadBalancingOnStickyCookie {</div><div> if (req.http.Cookie ~ "JSESSIONID=") {</div>
<div> set req.http.StickyVarnish = regsub( req.http.Cookie, "^.*?JSESSIONID=([^;]*);*.*$","\1" );</div><div> call chooseBackend;</div><div> unset req.http.StickyVarnish;</div><div>
} else {</div><div> call chooseBackend;</div><div> }</div><div>}</div></div><div><br></div><div><div><div>sub chooseBackend {</div><div> if (req.http.StickyVarnish ~ "back01a$") {</div><div> set req.backend = back01a;</div>
<div> } else</div><div> if (req.http.StickyVarnish ~ "back01b$") {</div><div> set req.backend = back01b;</div><div> } else</div><div> if (req.http.StickyVarnish ~ "back02a$") {</div>
<div> set req.backend = back02a;</div><div> } else</div><div> if (req.http.StickyVarnish ~ "back02b$") {</div><div> set req.backend = back02b;</div><div> } else</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>##default</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>set req.backend = wwwround;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div>}</div></div></div><div><br></div><div>sub vcl_error{</div><div><div><br></div><div>if (obj.status == 404) { </div><div> set obj.http.Location = "<a href="http://server.de/404/index.html?WT.mc_id=varnish_error404">http://server.de/404/index.html?WT.mc_id=varnish_error404</a>";</div>
<div> set obj.status = 302;</div><div>}</div><div><br></div><div>if (obj.status == 503 && req.restarts < 4) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>set req.backend = wwwround;</div>
<div> restart;</div><div> } else if (obj.status == 503 && req.restarts >= 4)</div><div> { </div><div> set obj.http.Location = "<a href="http://server.de/500/index.html?WT.mc_id=varnish_error503">http://server.de/500/index.html?WT.mc_id=varnish_error503</a>";</div>
<div> set obj.status = 302;</div><div>}</div><div><br></div><div>}</div></div>