client and fallback director questions.

James A. Robinson jim.robinson at stanford.edu
Wed Oct 2 04:47:06 CEST 2013


Hello,

I've got a question about varnish's director capabilities, and I
was hoping someone here could help me understand the capabilities
of varnish.

Right now we've got a varnish server acting as a load balancer for
three backends that are supposed to contain identical content.

In realiity, small differences can exist as an update process visits
each backend in turn, updating its content before proceeding onto
the next.

To minimize the possibility of a request seeing an inconsistent
view of the backend, we're grouping requests by path to route them
to a particular backend.  E.g., requests with path /a/ get sent to
backend #1, requests with path /b/ get sent to backend #2.

So we have backend configurations similar to this:

backend b1 {
.host = "b1.example.org";
 .port = "80";
}

backend b2 {
.host = "b2.example.org";
 .port = "80";
}

backend b3 {
.host = "b3.example.org";
 .port = "80";
}

And our vcl_recv section has something like this in it:

if (req.url ~ "^/(a|b|c|d)[\.\/]") {
 set req.backend = b1;
}
else if (req.url ~ "^/(e|f|g|h)[\.\/]") {
set req.backend = b2;
}
else
set req.backend = b3;
}

The problem with our setup is that we would like to introduce fail
over capabilities, but it's not clear how to introduce a director
that route all traffic for path /<x>/ to backend #<n> except in the
situation where we detect that backend is down.

The documentation discusses a client director, and it seems like
it might be possible to use that to enable our fallback logic.
Basically to say that, based on the path prefix, to set an identity
of X and consistently route to an available backend.  But I'm unclear
on whether or not the client director will perform any sort of
fallback logic if a backend that it *was* routing to fails its
probe?

Say we define a .probe:

backend b1 {
 .host = "b1.example.org";
 .port = "80";
.probe = {
 .url = "/";
.timeout = 34 ms;
 .interval = 1s;
.window = 10;
 .threshold = 8;
        }
}

backend b2 {
.host = "b2.example.org";
 .port = "80";
.probe = {
 .url = "/";
.timeout = 34 ms;
 .interval = 1s;
.window = 10;
 .threshold = 8;
        }
}

backend b3 {
.host = "b3.example.org";
 .port = "80";
.probe = {
 .url = "/";
.timeout = 34 ms;
 .interval = 1s;
.window = 10;
 .threshold = 8;
        }
}

and we set up a client director:

director member client {
{
 .backend = b1;
.weight = 1;
 }
{
.backend = b2;
 .weight = 1;
}
 {
.backend = b3;
 .weight = 1;
}
}

and then we set client.identity based on our regexes:

if (req.url ~ "^/(a|b|c|d)[\.\/]") {
 set client.identity = "group-1"
}
else if (req.url ~ "^/(e|f|g|h)[\.\/]") {
 set client.identity = "group-2"
}
else
set client.identity = "group-3"
}

If the backend pool shrinks from 3 to 2 because one of the backend
servers fails its probe,  will traffic that was getting routed to
that backend get rerouted?

Someone has also pointed out to me the fallback director, and how
it might be possible for us to create several pools to indicate
fail-over order.  E.g., set b1 and b2 as one group, and b2 and b3
and another group, but I'm not grasping exactly how that would look.
It appears as though I'd need to set up multiple directors and use
restart to trigger fail over if a request to one director failed?

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20131001/b634fcaf/attachment.html>


More information about the varnish-misc mailing list