Its a duplicate question, though I want to ask it for more clarification on it.
I want to create a private chat using socket.io. While googling for it, I found 2 solutions:
- Use an array to store the active user list
- Use room concept
Suppose my app has millions of active users.
Here's what I want: I have my friend list in mysql db, and when I log in, I want all friends and their status (active or not).
case 1. If I use an array to store all active users, then it works pretty well, but is this a good way to store all users who are connecting to my app in an array?
case 2. If I use the room concept where each of users friend have a unique roomid, then whenever a user logs in, he has to join all those roomid. It also worked for me, but in this case, how do I know if my friend is active or not?
I want to know which of this solution will work for my app which will have millions of user, or is there any other way to solve this.