Keeping track of connected user with socket

110 views Asked by At

I need to keep tracks of users connection, disconnection and login time. I use sockets for this but I am troubled over some stuff. For now I created an array that keeps track of connection and disconnection from user.

Something like

const connectedUser = [];

So this is initialised at the launch of my server, and I add/delete values continuously.

Is there a better way to track what I want ?

For now I have like a few thousands users, so it's not that huge. But I question this in term of scalability. For like a 100k users, i'm not sure this would be the proper way to handle this issue.

Any advice is appreciated, thank you !

Edit: My app is Trello-like. Users can create/like/comment "issues". They can also see which user is connected and send dm.

So what I implemented served this purpose -> See who is connected in real time and send messages.

I thought that this data is volatil, there is no purpose to store this data. So that's why I use array. Wouldn't it be a waste of storage to store this data ?

0

There are 0 answers