Sticky sessions with Authorization header for Sanic workers

Hi,

I’m using python-socketio with Sanic. However, python-socketio only works when there is 1 Sanic worker running in the application.

I did raise this up to python-socketio and the author suggests having a load balancer to redirect requests to multiple Sanic apps (each with 1 worker): https://github.com/miguelgrinberg/python-socketio/issues/371

My question is: is it possible for Sanic to have its own sticky sessions for the workers ?

short answer: no, workers can’t handle sticky sessions. The next available worker will handle the request.

Longer answer: while it’s not necessarily possible to have sticky sessions in place, you may be able to use shared state storage to get around that depending on how that happens.

From reading your issue, the answer given by the socketio folks is correct: you would need to run multiple single-worker instances of sanic and set up a load balancer with sticky sessions in order to enable what it sounds like you’re trying to accomplish.

I see. Thank you for the reply.

I will try out and see what I can do.