Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: please make sticky sessions requirement louder #1099

Closed
abe-winter opened this issue Dec 12, 2022 · 4 comments
Closed

docs: please make sticky sessions requirement louder #1099

abe-winter opened this issue Dec 12, 2022 · 4 comments
Assignees

Comments

@abe-winter
Copy link

abe-winter commented Dec 12, 2022

Is your feature request related to a problem? Please describe.
When run as a cluster, this library requires sticky sessions to be enabled. This wasn't obvious at first and so I deployed a buggy cluster.

Please improve the docs or errors to make this requirement clearer (and I'm happy to submit a docs / error message PR, if helpful).

(Also thank for for providing this library -- I am very happy to be able to run my socketio backend in my existing fastapi stack).

Describe the solution you'd like
In the codebase:

  • remove the sticky sessions requirement if possible (I don't understand the internals of this project or the socketio protocol, but I assume the sticky sessions requirement is in here for a legit reason, and removing it would be a large project if possible)
  • explain the situation in the error message, if possible. In my case the error is usually 'Invalid session', presumably from 2 places in handle_request

In docs:
In the using a message queue section, can you link to the scalability notes warning (which says to use sticky sessions), and make it clear your cluster will fail if you don't meet the reqs?

Describe alternatives you've considered
The alternative I tried first was having my chat intermittently fail in prod. Because my cluster is small, it usually connected eventually, so for a while I assumed it was an error in the ordering of my authorization logic + socket connection.

Logs
n/a, but let me know if you want me to capture something

Additional context
Did a readthrough of other issues mentioning this:

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Dec 12, 2022

There is a section under Deployment that is specifically dedicated to scalability. How can it be louder?

https://python-socketio.readthedocs.io/en/latest/server.html#scalability-notes

@abe-winter
Copy link
Author

When I initially set up my cluster, I focused on the using a message queue section because it had the phrase 'horizontal scaling' in it, and because I expected that I would need to connect to a routing layer

I also focused on the ASGI section, but the rest of the deployment section was a list of alternate deployment methods. It didn't occur to me that the last item in that list would be a critical todo item for clustering.

Maybe:

  • link to 'scalability notes' from the 'horizontal scaling' bullet point? (and say that 'you MUST do this')
  • consider renaming from 'scalability notes' to 'clustering requirements'? 'notes' doesn't make this seem critical

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Dec 12, 2022

and say that 'you MUST do this'
'notes' doesn't make this seem critical

Sticky sessions are optional.

Only required if you want to use the polling transport. It's very common to remove the sticky sessions requirement by configuring clients to connect directly through WebSocket, which is a single request, so no need for session affinity.

But the point is well taken, anyway. I will review how to organize the content better.

@abe-winter
Copy link
Author

non urgent obviously, thanks for the attention

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

No branches or pull requests

2 participants