Q: multiple backends

C. Handel fragfutter at gmail.com
Fri Jul 6 13:04:46 CEST 2007


On 7/6/07, Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:
> In message <20070705181517.GA5791 at falcon>, Christoph writes:
> >Hi,
> >
> >are there any plans to include support for multiple backends in varnish?
>
> You can already use multiple backens in Varnish.
>
> >It would be great to have either fault-tolerance and/or simple
> >load-balancing.
>
> Yes, this is indeed on our plans,  I keep trying to get somebody to
> tell me how it should work, but with very little luck :-)
>
> Just saying "fault-tolerance" or "load-balancing" isn't saying much
> you see, we need to formulate strategies and algorithms...

for fault-tolerance the proposal from anton stonor could be used.
Extend it with the backend-name

># First, we setup decide how to "sniff" that a backend is down
>#
># options_ping: Send a HTTP OPTIONS (Perlbal does that)
># timeout: 	If the backend does not answer within x seconds, it is
>#          	probably down
># icp: 		Abuse the protocol. (Squid + Zope does that)
>backend.default.down_protocol = options_ping | timeout | icp

># What is the timeout limit?
>backend.default.timeout = 30

backend main {
        set backend.host = "IP";
        set backend.port = "80";
}
backend backup {
        set backend.host = "IP";
        set backend.port = "80";
}



then we could use

sub vcl_recv {
   set req.backend = main
   if (backend.main.down) {
      set req.backend = backup
   }
}



for loadbalancing we could either extend the backend definition

backend main {
        set backend.1.host = "IP";
        set backend.1.port = "80";
        set backend.1.weight = 1;
        set backend.2.host = "IP";
        set backend.2.port = "80";
        set backend.2.weight = 1;
}

or introduce a new balancer (i don't know if we could just nest backends)

balancer mainbl {
   set balancer.strategy = "roundrobin";
   # set balancer.strategy = "random";
   backend one {
      set backend.host = IP;
      set backend.port = 80;
      set backend.weight = 1;
   }
   backend two {
      set backend.host = IP;
      set backend.port = 80;
      set backend.weight = 1;
   }
}

and use it

sub vcl_recv {
   set req.backend = mainbl
}



Greetings
   Christoph



More information about the varnish-misc mailing list