Sticky sessions in fastrouter/httprouter #83

Closed
unbit opened this Issue Dec 11, 2012 · 1 comment

Comments

Projects
None yet
1 participant
Owner

unbit commented Dec 11, 2012

When some kind of async database replica is in place, having the same client connecting to the same backend is the best solution to avoid incongruences in responses (mainly caused by sync gaps)

Sticky sessions are a common technique, but as always i want to give them to uWSGI users with little effort from a code-changing point of view.

My idea is setting a cookie in the fastrouter with the address of the backend (encrypted).

The encrypted blob should contain the ip address of the client, the backend node (obviously), a random IV and should support different kind of keys (from preshared keys to the same certificate used by the secured subscription system)

If the fastrouter find the cookie already set in the request it will simply decrypt it and use the supplied address.

Obviously an api function could be added (like uwsgi.sticky()) to generate the encrypted blob from the app only for the requests requiring it.

Owner

unbit commented Jul 12, 2014

now it is easy to implement custom algos for routers. The uWSGI 2.1 iphash one should be used for stickyness

unbit closed this Jul 12, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment