Sticky Session with an assignable backend

Oddur Snær Magnússon oddur at
Mon Oct 22 19:49:21 CEST 2012

I have a problem where I need to be able to do "sticky session" based on some identity, but be able to tell varnish which identity belongs to which backend.

In my case, I have a value in the request header(oauth token) which should always go to the same backend. I begin by sending the request to a random backend, and if the users session does not live on that backend I get X-Accel-Redirect header back telling me which backend that request should go to.  I can easily do that part using a restart and send the request to the correct one.

But  from then on I want to remember that that specific identity should always go to that given backend.

I'm not aware of being able to store any such mapping inside varnish, so I thought about using the memcached vmod to store the mapping and then looking it up on each request.  I have not tried it yet so I'm not sure what the performance hit will be on that extra memcached lookup per request.   But in fact, I think it's an overkill since all I need is way to access a in memory hashtable within my vcl.

Would it be possible to "control" the client backend director, mapping a specific identity to a backend ?
Is there a known way to access a hashtable which is shared by the workee threads within a varnish instance, possibly using inline c?

Best regards,

Oddur Snær Magnússon
Senior Programmer | CCP Games | Reykjavík | Iceland


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list