Replies: 1 comment 2 replies
-
First of all, if this is a timer, why can't each client keep track of the countdown on its own, maybe receiving an update from the server from time to time just to keep it synchronized? That should reduce traffic considerably, and allow you to have more clients on a single worker. Maybe then you don't need to add more workers. If you do want to add more workers, then how to handle the timer is a matter preference. You can have a main worker that handles the timer, or you can use a non-server process to run the timer and emit the updates through redis. It's really up to you how to do this. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey Miguel,
Firstly, thank you for this awesome package!
Im currently building an application with SocketIO that has a countdown timer at its core. I start the timer with a background process and it's a fairly simple While Loop. So far so good and currently working fine.
For better visualisation, Imagine a quiz app for 50 - 100 concurrent users (they are one collective team). the Quiz has a timer of 10 seconds for each question and some users have jokers to increase the countdown for all. For clarification, there is 1 "main" countdown, for everybody.
Now, thinking about scaling this application I hit my (very limited) server knowledge. It is currently running gunicorn as web server, using the eventlet workers, as described in your docs. You also mentioned that this setup can only use one worker process.
While I looked into the next section about "Using Multiple Workers", I am concerned that it will spawns multiple countdowns which should not happen. At all times, only 1 "main" countdown shall be present to ensure validity across all users.
Sorry for my naive questions, but is there a way to scale up to handling more requests with only 1 background process? Or maybe outsource the background task completely outside of Flask SocketIO and maybe let Redis propagate the countdown across the instances? Would you have another idea?
Thank you very much in advance!
Beta Was this translation helpful? Give feedback.
All reactions