GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
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.
now it is easy to implement custom algos for routers. The uWSGI 2.1 iphash one should be used for stickyness