I have two Varnish servers, in a middle-tier between an F5 load balancer and two application servers (Apache httpd). I want Varnish to split the load more-or-less evenly between the two Apache servers. Here's the important bits of the configuration I'm using:
backend prod1 {
.host = "172.16.1.1";
.port = "80";
}
backend prod2 {
.host = "172.16.2.1";
.port = "80";
}
director wpprod client {
{ .backend = "prod1"; .weight = 1; }
{ .backend = "prod2"; .weight = 1; }
}
sub vcl_recv {
set client.identity = req.http.user-agent;
set req.backend = wpprod;
}
The intent is to take a header that shouldn't change during a session, but should be semi-random (the client's User-Agent: header), and use it to split the load between the two back-end servers.
Unfortunately, in practice, the load is being split about 70-30, with one backend getting roughly twice as much traffic as the other.
I've also tried using the X-Forwarded-For: header that my F5s are adding as the client.identity, but had the same problem.
I could just tweak the weights a bit, to try to even out the load, but that's not really scalable, or feasible with more than a few servers.
Any suggestions on headers I can use that will result in a more even split of traffic?