Wednesday, August 11, 2010

Varnish - cache "invention" - Load balacing squid's

I tested load balacing squid proxys with HAproxy, and it was nice, then i had a crazy thought;
"what if i used varnish, and load-balance "and" cache at the same time...?"

Varnish its a great software for reverse-caching webservers... i'm not using it for what it was created, but i had this crazy idea...:P

Well, i took varnish and started "inventing" a way...

This is my setup to load-balance and cache, with varnish, 3 squid's :P (yep, crazy i know):

Request---> varnishd:8080 --> refered has "webfarm"
            /    |    \
           /     |     \
       proxy1  proxy2  proxy3

config file: default.vcl

 backend proxy1 {
     .host = "10.30.1.171";
     .port = "8080";
 }


 backend proxy2 {
     .host = "10.30.1.172";
     .port = "8080";
 }

 backend proxy3 {
     .host = "10.30.1.173";
     .port = "8080";
 }

 director webfarm round-robin {
 {
  .backend = proxy1;
 }
 {
  .backend = proxy2;
 }
 {
  .backend = proxy3;
 }
 }

 sub vcl_recv {
  if (client.ip == "10.1.5.10" )
   { set req.backend = webfarm; }
}.


Well it worked...but i'm not very sure about the perfomance...varnish was not created for this :P
.

No comments: