node.js - Implement facebook style status message system in mongodb -
How can we apply Facebook in Mangode (using Mongoose) like a messaging system, where anyone The user takes the position of his position
This should not be a real time, there will be a fresh button to get the latest position.
Plan A: Plan B: Status (collection) ID, user_id (reference), status_msg, friends_list [sub-document] Advantages: Speed at high speed With Plan A., Friends will have to loop among all the friends and then get all the positions for me every single friend to do this Will be (page refresh / new login). With Plan B, I only have to get the information of the situation in the Friends_list of current user Would I want to know my opinion and suggestions on this? Is there a better way to deal with this problem? I should also know how I can use the Rabbit MQ here to increase efficiency and reduce unnecessary DB I / O. Believing that each user will have many friends, and these friends have their time limit several times Refresh the times, you can assume that reading will be more than writing. This means that in terms of pure performance you will optimize for reading-access, not to write, will store the receiver with the message. However, keep words in mind. What if the status change in the author's friend list changes after posting? When the answers to these questions are yes, you should set the receiver on the reader as compared to writing. There is also a third option which can be considered for consideration: Do not handle the message by the sender, handle them by the receiver. When a message sends a message, make a personal copy of the message for each of your friends and save them as separate documents. Then you ask for your message archive for messages, where they are receivers, can get all the messages for the user. The friend / unrestricted operation will then need to check any messages that need to be added / removed. The main drawback of this approach will be that users posting a very high load will create a very high load weight.
Status (collection) ID, user_id
Comments
Post a Comment