miguelgrinberg / python-socketio

Python Socket.IO server and client
MIT License
4.01k stars 589 forks source link

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

Closed maybephilipp closed 10 months ago

maybephilipp commented 12 months ago

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 commented 12 months ago

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 https://github.com/miguelgrinberg/python-socketio/issues/1239.

miguelgrinberg commented 10 months ago

References to gevent-websocket have been removed.

lsapan commented 8 months ago

@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 commented 8 months ago

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

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

lsapan commented 8 months ago

@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! ✨