Replies: 11 comments
-
No. You can keep track of the users that are connected by adding connect and disconnect handlers. |
Beta Was this translation helpful? Give feedback.
-
The disconnect event isn't working or triggering on when a client closes connection . Can you please show a working example sir? |
Beta Was this translation helpful? Give feedback.
-
There is an example in this repository. |
Beta Was this translation helpful? Give feedback.
-
Okay sir thanks. But I have a doubt. Can we make large big Web app for millions of incoming requests with flask and flask socket io? And does |
Beta Was this translation helpful? Give feedback.
-
@Gokul-44 Do you have any specific concerns? Big apps are hard to write, it has nothing to do with Flask or any framework and everything to do with the developer. |
Beta Was this translation helpful? Give feedback.
-
Sir just think of a website having minimum 2k requests per second. Does flask can handle it? And if we use flask socket io we can use only one worker so can we make another python file and use threads or multiprocessing for running multiple servers on multiple ports using os module and add all the servers lists like http://localhost:5555, http://localhost:5556... in nginx and use load balancer like that? I don't know if you get what I meant sir but I made a website with flask and flask socket io and hosted in one single ec2 instance behind nginx. But because of using one worker it can't accept large concurrent requests. So can you suggest a way or can you tell me if the thing I mentioned above of using multiprocessing or threading work like load balancer? |
Beta Was this translation helpful? Give feedback.
-
As I said above, the request logic is going to be implemented by you. You have to write efficient code in your request handler that allows you to scale as much as you need. Flask has nothing to do with this, the amount of work that Flask does compared to your own business logic is in the noise.
Have you read the documentation? You can use multiple workers. You can scale Socket.IO horizontally as much as you need. |
Beta Was this translation helpful? Give feedback.
-
Okay sir. One thing this I have only one ec2 server instance so can run multiple server with different ports parallel like main_app.pyimport os, threading nginx confupstream socketio_nodes {
} server {
} Can we run loadbalance like this by running main_app.py and nginx 8n same server instance? Sorry sir if iam wrong.. |
Beta Was this translation helpful? Give feedback.
-
It's really hard for me to look at code or nginx configuration and tell you if it is correct or incorrect. In general the approach is correct, as long as you also have a message queue, which is required when you use more than one server. |
Beta Was this translation helpful? Give feedback.
-
Okay sir. But I face a problem now the when I host with gunicorn or uwgi in a ec2 instance it is very slow for opening in browser. But if I use flask development server it opens very fast. Do you know what will be the reason sir? |
Beta Was this translation helpful? Give feedback.
-
I don't, sorry. Have you looked at logs? |
Beta Was this translation helpful? Give feedback.
-
Sir is there any way to get currently connected users lists of sid? And get users list of sid from a room?
Beta Was this translation helpful? Give feedback.
All reactions