Is a flat socket one number per user? expensive?

I have flash webapp executing pandas to do some data analysis on the backend.

Currently, I have taken a naive approach to using AJAX to send user requests to the server and interact with data. but as it turned out, with each request there is a lot of overhead, and every time I need to reload the data in pandas / memory, which is very repeated.

I thought socketio could be useful here - I would open the socket connection, and thus, as soon as the file is loaded into pandas, the user can interact and request data more quickly with less overhead through the socket.

So my question is right now:

  • Should I open a room for each user, since users do not need to interact with each other?
  • Is this scale opening a room for every user?
  • Where does the namespace fit here? Do I assign a namespace to different sections of the website and then open the rooms under each namespace for each user?
  • Or should I spawn a headless thread? Greenlet per user?
+5
source share
1 answer

Opening a room for each user is the right decision, which I usually recommend as a way by which you can easily contact individual users in messages with the server.

Numbers are stored in the Python data structure in memory, so they are expensive only because they use a little memory. I did not estimate the quantity per user, but it is probably just a few bytes on top of the room name.

The namespace is used to multiplex several different connections into one physical channel. If you just have one connection, just use the same namespace for everything. You should use several namespaces if, for example, there are two client applications on your page (for example, angular apps), each of which has its own set of event handlers. In addition, there is no reason to use more than one namespace.

Hope this helps.

+8
source

Source: https://habr.com/ru/post/1213973/


All Articles