if obj.status == 50[1|2|3|x] -> reissue request on next backend(s)

Gerald Leier gerald.leier at lixto.com
Tue Sep 1 17:15:14 CEST 2009


Hello again,

thanks for the fast answer!

unfortunatly i am still stuck.

On Tue, 2009-09-01 at 09:48 +0000, Poul-Henning Kamp wrote:
> In message <1251797169.13050.48.camel at pioneer>, Gerald Leier writes:
> >hello again,
> >
> >Is or isnt it possible to make varnish ask another backend
> >if the first returns a HTTP 500 or any other user defined
> >HTTP code when forwarding a users request?
> >
> >and if its possible -> whats the varnish way to do that?
> 
> Use the "restart" facility, which basically tried the request
> once more from the beginning, with any possible modifications
> you have made or will make.
> 
> Typically, you would set another backend in vcl_recv{},
> something like:
> 
> 	...
> 	if (req.restarts > 0) {
> 		set req.backend = better_one;
> 	} else {
> 		set req.backend = normal_one
> 	}
> 

my setup consists of 3 machines.
 1 loadbalancer
 2 webservers(applicationservers)

varnish version used:
 varnishd (varnish-2.0.4)


i really do want to test nothing more then:
 have two content servers.
 round robin select one of them.
 if the selected returns a 50x -> forward request to other node
 i dont need cashing, i dont need funny rewriting,
 i dont need to embed fancy C code into VCL.
 nothing like that.

 i even checked out and compiled the latest varnish because i thought:
http://varnish.projects.linpro.no/changeset/3948
 (have been rolling back to 2.0.4 since then for "my" vcl code and the
  2.1...varnish made it even worse)

i dont want to post my whole config again. last time i did that
no one seemed to think its worth answering such "massiv amounts"
of spam.
(Subject: cant get restart; to fetch and deliver from other backend on
HTTP error)


so here i am, with snipplets
.........
backend test1 {
        .host = "10.10.10.20";
        .port = "80";
}

backend mars1 {
        .host = "10.10.10.30";
        .port = "80";
}
.........

.........
sub vcl_recv {
        if (req.restarts > 0) {
                set req.backend = test1;
        } else {
                set req.backend = test2;
        }
.........

.........
sub vcl_fetch {
    if (obj.status == 500 || obj.status == 503 || obj.status == 504) {
            restart;
    }
.........

=> 503 guru meditation.

any hints, links or examples are very welcome.

i dont like to give up on something i spent a few days on by now...
at least not now. that of course may change if i dont get this baby
up and running within another few days.

lg
 gerald


> 
-- 




More information about the varnish-misc mailing list