Varnish as load balancer

Tollef Fog Heen tfheen at
Mon May 18 11:13:24 CEST 2009

]] "Carlos Oliva G." 

| In the current setup I'm skipping Lighttpd altogether and began using  
| Varnish as a load balancer altogether as well, with the 'directors'  
| feature. However I'm still missing the last bit of the requested  
| functionality that is to evenly balance all the requests from  
| 'anonymous' users that aren't registered/logged into the system (which  
| I am already identifying in the sub_rcvd function of my VCL), but for  
| registered users to preserve their session by redirecting them always  
| to the same backend server. I know I can create a 'hash' using some  
| relatively unique values, as the originating IP address + the User  
| Agent and a session-dependent cookie value, but what I don't know is  
| (if possible), how to use this hash to determinate to what backend  
| server to direct the request to.

We currently don't have a hashing load balancer (which is what you seem
to want).  (Patches accepted, or Redpill Linpro can get you a quote on
how much work it is to develop it.)

What you could do is have the backend set a cookie with its name when
the user logs in, and then choose backend depending on cookie value.

Another alternative is to use nginx or similar as Varnish' backend and
let that do the hashing and load balancing.  I have been told it's quite
good, but I don't have experience with it myself.

Tollef Fog Heen 
Redpill Linpro -- Changing the game!
t: +47 21 54 41 73

More information about the varnish-misc mailing list