You'd be better off using the random director for cr-backends as each
varnish defines the director.

For the varnishes, you probably don't want to use a director, but
check the next varnish in the ring. Requests to another varnish should
be much cheaper than going to the backend, and you want to fill up
each varnish as you go around to minimise backend requests.

sub vcl_recv {
   set req.backend = next_varnish;
   # Keep a unary count of how many varnishes this request has been through
   if (!req.http.X-Via-Varnish) {
       set req.http.X-Via-Varnish = "1";
   } else {
       set req.http.X-Via-Varnish = req.http.X-Via-Varnish "1";
   }
   if (req.http.X-Via-Varnish ~ "1111" || !req.backend.healthy) {
       # Request is coming from the other server.
       set req.backend = cr-backends;
   } else {
       set req.http.X-Via-Varnish = "true";
   }
}

This is more complex than a pair though, so not sure what you want to
do about the hash_ignore_busy here.

Laurence

On 10 February 2011 16:37, Ben Dodd <[email protected]> wrote:
> Something like this:
>
> director cr-backends round-robin {
>  .retries = 5;
>
>  {
>    .backend...
>  }
>
>  # Repeat the above entry for each web server.
> }
>
> director cr-varnish round-robin {
>  .retries = 4;
>
>  {
>    .backend...
>  }
>
>  # Repeat the above entry for each varnish server.
> }
>
> sub vcl_recv {
>
>  set req.backend = cr-varnish;
>
>  if (req.http.X-Via-Varnish || req.restarts > 3) {
>    # Request is coming from the other server.
>    # Ignore busy objects to avoid race condition.
>    set req.hash_ignore_busy = 1;
>    set req.backend = cr-backends;
>  } else {
>    set req.http.X-Via-Varnish = "true";
>  }
> }
>
> Thanks, Ben
>
> On 10 Feb 2011, at 14:14, Martin Boer wrote:
>
>> I would also add weights so that each varnish prefers to ask its sibling
>> say 250 times more often than asking the app-server.
>> This will ensure that both varnishes will be as filled and as equal as
>> possible.
>> I don't know if 250 could be replaced by a larger number but this works
>> for me.
>>
>> Regards,
>> Martin
>>
>> On 02/10/2011 02:46 PM, Laurence Rowe wrote:
>>> On 8 February 2011 23:05, Ben Dodd<[email protected]>  wrote:
>>>> Given this functionality, does anyone know what the VCL is required to 
>>>> implement this dual server Varnish setup scenario?
>>>> http://varnish-cache.org/trac/wiki/VCLExampleHashIgnoreBusy
>>> Something like this should work:
>>>
>>>
>>> backend appserver { ... }
>>> backend other_varnish { ... }
>>>
>>> # Server 1
>>> sub vcl_recv {
>>>     set req.backend = other_varnish;
>>>     if (req.http.X-Via-Varnish || !req.backend.healthy) {
>>>         # Request is coming from the other server.
>>>         # Ignore busy objects to avoid race condition.
>>>         set req.hash_ignore_busy = 1;
>>>         set req.backend = appserver;
>>>     } else {
>>>         set req.http.X-Via-Varnish = "true";
>>>     }
>>> }
>>>
>>> # Server 2
>>> sub vcl_recv {
>>>     set req.backend = other_varnish;
>>>     if (req.http.X-Via-Varnish || !req.backend.healthy) {
>>>         # Request is coming from the other server.
>>>         set req.backend = appserver;
>>>     } else {
>>>         set req.http.X-Via-Varnish = "true";
>>>     }
>>> }
>>>
>>> Laurence
>>>
>>> _______________________________________________
>>> varnish-misc mailing list
>>> [email protected]
>>> http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>>
>>>
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the MessageLabs Email Security System.
>> For more information please visit http://www.messagelabs.com/email
>> ______________________________________________________________________
>
>
> Comic Relief  1st Floor  89 Albert Embankment  London SE1 7TP  Tel: 020 7820 
> 2000  Fax: 020 7820 2222  [email protected]  www.comicrelief.com
>
> Comic Relief is the operating name of Charity Projects, a company limited by 
> guarantee and registered in England no. 1806414; registered charity 326568 
> (England & Wales) and SC039730 (Scotland). Comic Relief Ltd is a subsidiary 
> of Charity Projects and registered in England no. 1967154. Registered 
> offices: Hanover House, 14 Hanover Square, London W1S 1HP. VAT no. 773865187.
>
> This email (and any attachment) may contain confidential and/or privileged 
> information. If you are not the intended addressee, you must not use, 
> disclose, copy or rely on anything in this email and should contact the 
> sender and delete it immediately. The views of the author are not necessarily 
> those of Comic Relief. We cannot guarantee that this email (and any 
> attachment) is virus free or has not been intercepted and amended, so do not 
> accept liability for any damage resulting from software viruses. You should 
> carry out your own virus checks.
>

_______________________________________________
varnish-misc mailing list
[email protected]
http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to