flask-socketio one room per user ? expensive? flask-socketio one room per user ? expensive? flask flask

flask-socketio one room per user ? expensive?


Opening a room per user is a valid solution that I usually recommend as a way to easily be able to address individual users in server-pushed messages.

The rooms are held in a Python data structure in memory, so they are only expensive in that they use a little bit of memory. I have not measured the amount per user, but it is probably just a few bytes on top of the room name.

The namespace is used to multiplexing multiple different connections into one physical channel. If you just have one connection, then just use the same namespace for everything. You should use multiple namespaces if, for example, you have two client-side apps in your page (such as angular apps), each with its own set of event handlers. Other than that there is no reason to use more than one namespace.

Hope this helps.