How should I build the architecture of my MongoDB database? I have a project about e-Sports. In this project, I have VDS Game Servers for players. With this game servers, our players will play Ranked Games and players will earn Matchmaking Rank Points for their rankings. When 10 players match in web application/desktop application/mobile application; the system will choose a server which one is idle and game will start. After the start of game, the status of Server will need to be changed real-time.

For example, Team A has 9 score and Team B has 10 score. When Team A got one more point, the match status should be [Team A 10 - 10 Team B] and I can get this changed in database.



Server documents look like this:

{
    ip: address.split(':')[0],
    port: address.split(':')[1] || 27015,
    pass: pass,
    live: false,
    map: '',
    maps: [],
    knife: false,
    score: [],
    round: 0,
    knifewinner: false,
    paused: false,
    freeze: false,
    unpause: {
        'TERRORIST': false,
        'CT': false
    },
    ready: {
        'TERRORIST': false,
        'CT': false
    },
    steamid: [],
    admins: [],
    queue: [],
    players: {},
    banner: '',
    pool: [],
    banned: [],
    picked: [],
    stats: ''
};




The Question

Should I use MongoDB for real-time changes (updates) in this project?

Thanks!
Should I use MongoDB for real-time changes (updates) in this project?


Yes, you can use MongoDB for real-time updates. There are two options available for real-time updates based on whether you are using MongoDB Atlas(Fully Managed Cloud MongoDB service) or Self managed MongoDB service.


Self Managed(On-Prem/Cloud) - From MongoDB 3.6 the new feature Change Streams got introduced. Change streams allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them.
MongoDB Atlas - This comes with a service called Stitch Triggers. This will enable you to execute application and database logic automatically, either in response to events or based on a pre-defined schedule. This is the backend uses the Change Streams functionality.


So MongoDB should be a perfect option for your requirement.