X
X
XiNull2021-09-04 06:27:18
go
XiNull, 2021-09-04 06:27:18

What is the best way to develop a chat server with rooms on WebSocket?

Hello.
There is a database (MySQL), tables in it:
----------------------------
- users [id, nickname, key, room_id, ...] (key - authorization key, room_id - last room the user was in)
- rooms [id, name, user_id, ...] (user_id - room owner)
----------- -----------------
There are two options on which language to write the server part of the chat, GoLang and Node.JS, i.e., two draft versions are written in two languages, but in two options stood in place.
Need to keep ~5000 people online.
With each authorization, we climb into the database (Sequelize / Gorm), check if there is such a user, if there is, then we get information about him, we send out to others that a new user has entered (to those in the same room).

The main problem is that there are additional fields in the database, which can change periodically from user actions.
Do not go into the database every time to give the user information about other users in his room (in which he is currently), about the new parameters of the room.
Storing user objects in arrays is probably not the best option. Under this, the adapter must also be written so that when the properties of an object in the array change, it also changes in the database. I don’t really want to use Redis, but I also need to write an adapter for updating it in the database.
Please, who understands this topic, tell me how to organize this whole thing in the most correct way and how it will be right to keep users in the rooms?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-09-04
@XiNull

What means

Do not go into the database every time to give the user information about other users in his room
?
You have a websocket, which means that operational information (changes) is transmitted to the client and not the full state by timer, which means that the client independently stores the necessary information in the javascript code in arrays or localstorage, if this is so critical

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question