if obj.status == 50[1|2|3|x] -> reissue request on next backend(s)
Gerald Leier
gerald.leier at lixto.com
Wed Sep 2 17:52:34 CEST 2009
hello again,
On Wed, 2009-09-02 at 11:15 -0300, Alexandre Haguiar wrote:
> This is my try...
>
> If you dont need cache you can try pass to pipe mode in vcl_recv so
> all requests will be passed to backend and no 503 error will appear.
>
> sub vcl_recv {
> if (req.restarts > 0) {
> set req.backend = test1;
> } else {
> set req.backend = test2;
> }
>
> pipe;
>
> Alexandre Haguiar
>
thanks, but this doesnt work as i desire.
i reduced my config a bit more to match your codesniplet:
(removed director)
------------------
backend test1 {
.host = "10.10.10.20";
.port = "80";
}
backend test2 {
.host = "10.10.10.30";
.port = "80";
}
sub vcl_recv {
if (req.restarts > 0) {
set req.backend = test2;
} else {
set req.backend = test1;
}
pipe;
}
sub vcl_fetch {
if (obj.status == 500 || obj.status == 501 || obj.status == 502 ||
obj.status == 503 || obj.status == 504) {
restart;
}
}
sub vcl_deliver {
deliver;
}
--------
setup: test1 returns HTTP/1.1 500 Internal Server Error
test2 returns HTTP/1.1 200 OK
now with the above config varnish does
give the request to test1 -> return the 500 error to client :(
thats not what i want :(
please tell me if i am trying to use varnish for something it isnt
intended to be used for.
by now i think i may be playing with the wrong tool.
thanks for any hint
gerald
>
> On Tue, Sep 1, 2009 at 12:15 PM, Gerald Leier <gerald.leier at lixto.com>
> wrote:
> 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
>
>
> >
> --
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
>
>
>
> --
> Alexandre Haguiar
--
More information about the varnish-misc
mailing list