Varnish load balancer & (keep session)

Sam Crawford samcrawford at gmail.com
Sun Feb 7 14:28:34 CET 2010


Axel - Can I assume you have a single Varnish instance balancing over
the two Apache instances? If so, then another option would be to use
some kind of home-grown source IP stickyness to force connections from
one half of the Internet to one backend, and connections from the
other half to the other backend. I'm not sure if you'd need to dip
into C, but it should be possible to do something like "if (srcip % 2
== 0) { backend = b1; } else { backend = b2; }"

You can still support failover by calling checking the status of
backend.healthy, and change the backend to the alternative if the
preferred one is down.

Thanks,

Sam


On 7 February 2010 12:33, Rob S <rtshilston at gmail.com> wrote:
> Hi,
>
> To answer some of your questions:
>
> 1) 503 error when shutting down a backend:  When you shutdown the
> backend, do you see varnishlog say that the backend is healthy or sick?
> If one is sick, then the other should get the traffic if your VCL
> contains set req.backend = b1;
>
> 2) Vanish load balanced does not keep e-commerce sessions for PHP.  The
> simplest solution to this is to install memcache, and put the following
> lines in your php.ini file:
>
> [Session]
> session.save_handler = memcached
> session.save_path = "memcache-server1:11211,memcache-server2:11211"
>
> instead of session.save_handler = files
>
> However, I can't say for certain that this will definitely work - it
> depends on how your ecommerce application operates.
>
> 3) S-flag: I'm not sure about this, but my gut feeling is that it's not
> causing the problems you're seeing.
>
>
>
> Rob
>
>
> Axel DEAU wrote:
>>
>> Version: 2.0.6-1
>>
>> Insall: .deb
>>
>> Os: Debian 5.0.3
>>
>> Hi,
>>
>> I've got two backends running apache2: front1.domain.com &
>> front2.domain.com, set with the load balancing configuration
>> from http://varnish-cache.org/wiki/LoadBalancing.
>>
>> _The issue is, when I shutdown apache2 of the first backend varnish
>> don't switch to the second and display "Error 503 Service
>> Unavailable", is that a normal answer from varnish?_
>>
>> Other question, _does varnish load balancer keep php sessions, if yes
>> how will I do?_
>>
>> Varnishlog :
>>
>> 0 Backend_health - front1 Still healthy 4--X-RH 10 8 10 0.040008
>> 0.039814 HTTP/1.1 200 OK
>>
>> 0 Backend_health - front2 Still healthy 4--X-RH 10 8 10 0.066948
>> 0.066591 HTTP/1.1 200 OK
>>
>> The S flag is missing in my log, is that an issue…
>>
>> "4--X-S-RH" to notify that TCP socket shutdown succeeded
>> from http://varnish-cache.org/wiki/BackendPolling
>>
>> Part of default.vcl
>>
>> backend front1 {
>>
>>   .host = "front1.domain.com";
>>
>>   .port = "80";
>>
>>   .probe = { .url = "/";
>>
>>              .interval = 10s;
>>
>>              .timeout = 5s;
>>
>>              .window = 10;
>>
>>              .threshold = 8;
>>
>>  }
>>
>> }
>>
>>
>>
>> backend front2 {
>>
>>   .host = "front2.domain.com";
>>
>>   .port = "80";
>>
>>   .probe = { .url = "/";
>>
>>              .interval = 10s;
>>
>>              .timeout = 5s;
>>
>>              .window = 10;
>>
>>              .threshold = 8;
>>
>>  }
>>
>> }
>>
>>
>>
>> director b1 random
>>
>> {
>>
>>    { .backend = front1; .weight = 5; }
>>
>>    { .backend = front2; .weight = 1; }
>>
>> }
>>
>>
>>
>> #director b1 round-robin {
>>
>> #    { .backend = front1; }
>>
>> #    { .backend = front2; }
>>
>> #}
>>
>> Thanks for your help...
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc at projects.linpro.no
>> http://projects.linpro.no/mailman/listinfo/varnish-misc
>>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>



More information about the varnish-misc mailing list