[Varnish] #1595: Make hash director nice enough not to reshuffle clients

Varnish varnish-bugs at varnish-cache.org
Tue Sep 9 14:30:08 CEST 2014

#1595: Make hash director nice enough not to reshuffle clients
 Reporter:  zviratko  |       Type:  enhancement
   Status:  new       |   Priority:  normal
Milestone:            |  Component:  build
  Version:  unknown   |   Severity:  normal
 Keywords:            |
 I am re-implementing BigIP LTM logic and found a problem with how session
 stickiness can be implemented in varnish.

 When a previously unhealthy node goes up again, all clients previously
 reshuffled end on a different node, thus users are logged out again (first
 when it goes down, then when it goes up again). This is made worse if the
 node is flapping.

 I would love to see some possibility to do what F5 does

 1) a cookie is handed to the client, identifiyng the node in a pool that
 was chosen by the director logic
 2) when the node indicated in this cookie is sick, another one is chosen
 and the cookie is updated
 3) when the node goes up, all clients with cookie pointing to it end up
 here (those that didn't try to access it when it was down), while all
 clients that got reshuffled stay on their new nodes with no disruption

 Currently, I don't see a way to do this with VCL logic, at least not
 easily. I could copy backend_name to a cookie, but using it during request
 for backend selection would require a quite extensive array of IFs or a
 possibility to copy the string value to backend_hint, which is a different

 This would solve two things

 1) really sticky sessions when the node goes up again
 2) pool size changes consistency - new member will begin empty with only
 new sessions assigned to it. This might require temporarily increasing
 weight of the new node to accelerate it's population, though

 What I think can be actually done

 1) a new type of director which would handle the cookie-setting itself
 or at least
 2) possibility to set the backend from a cookie name, thus making it easy
 to implement in VCL like so:
 fresh client arrives -> node is chosen by director -> bereq is made ->
 beresp.http.Set-Cookie is added with value of beresp.backend.name
 old client with cookie arrives ->set req.backend_hint = req.http.Cookie
 (part of it with the backend name of course)->bereq is made (and if
 backend is sick, we delete the cookie and retry on a different one).

 I beg you to please make it at least possible to implement the workaround
 in 2), it would make it possible to match the true stickiness achieved
 with F5.

Ticket URL: <https://www.varnish-cache.org/trac/ticket/1595>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

More information about the varnish-bugs mailing list