Replies: 3 comments 2 replies
-
First you have to decide if you need an async server (green thread based) or a threaded server is sufficient. Green threads can scale much more efficiently, so they are usually considered a must if the server is going to be busy. In case this isn't clear, green threads (often called greenlets in Python) are somewhat similar to coroutines. Both make it possible to write asynchronous programs. These days most of the asynchronous innovation happens around asyncio, and while both eventlet and gevent are still maintained, they aren't as active as they used to be. You listed three options, but in reality you have six:
If your server isn't going to be busy, then the last option should be sufficient, and it is the one that will give you the least trouble. It seems you are trying to list at least one problem for each of the options to make a point, but the one you listed on simple-websocket is not valid, as this is documented behavior. If you don't specify which of these six modes you want to use explicitly by passing the Now for the greenlet options: The problem that you have with eventlet is an incompatibility with gunicorn. Eventlet is a very complex package that tends to break, so I always recommend not using the latest release. Downgrading to what others have deemed safe is actually a good idea. But if you don't want to do that, you can also drop gunicorn and use eventlet's own web server via For gevent, gevent-websocket is optional, but if you don't use it then you won't have WebSocket support in your server. Your claim that "dev/prod parity is a mess in Flask" should be directed at the Flask project which are also very responsive. No need to complain about that project here as I cannot help you with that. With gevent, you can also use uWSGI, but that is also a tricky package with a not so great reliability history, so yeah, there aren't great options these days for gevent. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the clarifications, they helped a bunch! FYI (for future generations 😅):
FYI, about using eventlet without gunicorn, the Flask docs mention this which may be worth keeping in mind:
There's no doubt a lot of frustration transpiring from my posts (sorry about that!) I love Python for scripting, but after spending 3 days on questions of deployment and dev-prod parity I'm not exactly enjoying myself 😅 Thanks again for the help! And the library! |
Beta Was this translation helpful? Give feedback.
-
Hey,
They relate to requirements for Flask-SocketIO and not Flask-SocketIO itself. As far as Flask-SocketIO is concerned, I can only say that having one recommended way of doing things (ideally with dev-prod parity) would have saved me a lot of time. And I take it would save others time as well. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For running Flask-SocketIO on gunicorn, the Deployment docs mention three options:
But which one comes recommended?
My experience with them today hasn't honestly been a lot fun:
The docs mention that:
What's the value of green threads and are they preferable to Gunicorn's threaded worker?
I'm running my app on Heroku. Would I be better inspired to choose an option other than gunicorn to start with?
Beta Was this translation helpful? Give feedback.
All reactions