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

Update documentation of usage with Gunicorn + gevent/eventlet #1280

Closed
maybephilipp opened this issue Nov 22, 2023 · 5 comments
Closed

Update documentation of usage with Gunicorn + gevent/eventlet #1280

maybephilipp opened this issue Nov 22, 2023 · 5 comments
Labels

Comments

@maybephilipp
Copy link

Describe the bug
Currently the documentation still states that for websocket support with Gevent, I need to use gevent-websocket. Same for Gevent + Gunicorn.

simple-websocket support was added in this commit so now the docs, in my opinion, should mention that nothing is needed for websocket support (batteries included). But maybe it worth mentioning the difference between two packages (I haven't found comparison, but in my opinion simple-websocket is just simpler to configure - almost nothing todo).

https://python-socketio.readthedocs.io/en/stable/server.html#gevent

Another question is: why doc says that gunicorn has some limitation of workers number if it's not really true? If I don't miss something, I could be true only if the app uses long-polling with sticky sessions, but otherwise I don't see any reason not to use >1 workers in gunicorn. Am I wrong?

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://python-socketio.readthedocs.io/en/stable/server.html#gevent'

Expected behavior
The doc shouldn't mention gevent-websocket unless it has some advantages as an alternative.

Logs
no logs

Thank you for your work! 🤗

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Nov 23, 2023

The doc update for gevent-websocket is being discused in #1272. I'm taking care of that.

Disabling long-polling allows you to use multiple workers in Gunicorn correct, but it has some disadvantages. And even without the sticky sessions, you still need to use a message queue for the workers to coordinate. I have been thinking about how to explain this in the documentation without making it even more convoluted than it is and at some point I'm going to reorganize the docs to better convey these options in addition to the more traditional ones. I have an issue for this work as well #1239.

@miguelgrinberg
Copy link
Owner

References to gevent-websocket have been removed.

@lsapan
Copy link
Sponsor

lsapan commented Mar 11, 2024

@miguelgrinberg sorry I know you're still working on #1239, but I'm wondering if you could briefly elaborate on these disadvantages:

Disabling long-polling allows you to use multiple workers in Gunicorn correct, but it has some disadvantages.

I'm currently exploring ways to get more throughput from my socketio servers, and using gunicorn with multiple gevent workers is something I was considering.

Any insight you have would be greatly appreciated!

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Mar 11, 2024

@lsapan I think this is less interesting than it sounds because in reality multiple workers have always been supported.

  • If you want to use long-polling and websocket both: Run multiple single-worker Gunicorns (each on a different port), and put a load balancer such as nginx in front of them with sticky sessions enabled.
  • If you want only websocket: You can run a single Gunicorn process with multiple workers, but clients attempting to connect with long-polling will get errors. This is because the Gunicorn load balancer does not support sticky sessions.

In both cases each instance of Socket.IO must connect to a message queue.

@lsapan
Copy link
Sponsor

lsapan commented Mar 11, 2024

@miguelgrinberg got it, thanks for clarifying! I just wanted to make sure I wasn't missing some unforeseen issue.

Thanks again for such an awesome library! ✨

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

No branches or pull requests

3 participants