How client.identity works?
Kristian Grønfeldt Sørensen
ksorensen at nordija.com
Sat Jul 20 14:10:39 CEST 2013
On Fri, 2013-07-19 at 20:29 -0300, Hugo Cisneiros (Eitch) wrote:
> I'm testing some configurations with the client director and
> cookie-based sticky sessions and want to know:
> How client.identity decides which backend to use?
> For example, if I have two servers with exactly the *same* backends,
> *same* VCLs, and a request is sent with client.identity =
> "ABCDEF1234567890" on BOTH servers, does both requests on both servers
> go to the same backend server? It could be true if using some sort of
> hash table.
It is my experience that this is the case, and I'm relying on this
behaviour in a couple of installations. IIRC, the director is an array
of backends, and the hashing ultimately returns an array index, so as
long as your director
* has the same number of backends
* has its backends defined in the same order
* has the same weights
* has the same view of backend health
on each Varnish instance, the same client.identity string will cause the
same backend to be chosen. So if one of your backends become sick as
seen only from the one of your Varnishes, then requests for that backend
will be routed differently between the two Varnishes.
> Or the client director first picks a random backend and associates its
> value to the client.identity, remembering for the future? This could
> be true if using some sort of a key:value table. This way, first
> scenario won't work reliably.
The client director does not save any state between requests.
More information about the varnish-misc