Answer the question
In order to leave comments, you need to log in
The architecture of the private messaging system?
Hello.
On the site you visit, you need to create a system of personal messages (text + pictures) for users from scratch (much like in VK, but much simpler). Please share your experience on how to do this more correctly from the very beginning, so that you do not have to redo it later on real users. The main task is to keep a large load well + correctly store large amounts of data (user messages) + scalability.
Should I use MongoDB/MySQL for this purpose? Store all messages in one table as text? If we split the data into shards, then what to do with the correspondence between users on different shards? What do you think about Node.js + Websockets for these purposes? How to properly store user messages on different servers?
Thank you.
Answer the question
In order to leave comments, you need to log in
Should I use MongoDB/MySQL for this purpose?
It is better to use PostgreSQL or MySQL for storage, but no one forbids you to use NoSQl, you do not need to store it in it, but use it as a cache
. What to write on?
Whatever you know how to do and write
The table structure is something like this
chat
id|from_user|to_user
message
id|chat_id|date
content
id|message_id|text
attached
id|message_id|path|ext
The key question is: are group chats possible in such a system?
If so, then the following tables are needed:
thread (session/topic)
thread_user (list of users, status of each, number of messages, including unread ones, date when the user read messages in this session for the last time, etc.)
thread_post - the messages themselves (so that it is stored in one instance, and not one for each user)
thread_links - a bunch of messages from thread_post and users (so that you can delete messages without affecting other users).
Otherwise, I agree with nirvimel , you need to use the SQL solution and write on what is well known.
Briefly: by channel (one session = one channel) with a breakdown into types.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question