Skip to content

Flask SocketIO Gunicorn Multiple Workers behind NGINX with Message Queue, correct understanding? #2045

Answered by miguelgrinberg
spmsh asked this question in Q&A
Discussion options

You must be logged in to vote

Option 1 is preferred, because it is fully compatible with the Socket.IO protocol. You can run multiple Gunicorn processes all on the same machine, each listening on a different port. Normally you'd want at least as many server processes as you have CPUs.

Option 2 can work too, but it is incompatible with the long-polling transport of Socket.IO. As long as you configure all your clients to connect directly through the WebSocket transport everything should work well, but long-polling clients will get 400 errors and will be unable to connect. In this case you will still need the message queue, but you can run a single Gunicorn server with multiple workers, probably as many as you have CPUs …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@spmsh
Comment options

Answer selected by spmsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants