T
T
TheRevan2021-05-16 21:00:04
Node.js
TheRevan, 2021-05-16 21:00:04

How to organize work with the database for the rest-api of the game?

Planned online game on node js - working through reast-api
How to organize work with the database? The game always works - 24/7 with possible server restarts. Not on sockets - just a rest api.
So far I see 2 options:
1st - the server has started - all records from the database are transferred to memory and one global Game object is allowed, and after loading - all users when they send requests to the server receive this data from this global object. And after when the server
is 2nd - we send requests to change data in real time using sequelize, for example, and we also request, respectively, not from memory, but from the database.

The question is the following - how best to organize the work, there are still better options, and also the question is - what problems can I face with the first and second options

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Kachan, 2021-05-19
@MANAB

Well, the database is needed in order to save the data and they are guaranteed to be there. Accordingly, it is necessary to organize the restart itself in the sense of player sessions, namely, to notify them that in N minutes the server will be restarted. If the games are session games, such as a room for X minutes of the game, then during a scheduled restart, do not allow the creation of new rooms / games and notify users about the upcoming restart.

1st - the server has started - all records from the database are transferred to memory and one global Game object is allowed, and after loading - all users, when they send requests to the server, receive this data from this global object. And after when the server

To take data from the database into memory for the duration of the server reboot - this is in whose memory, if the memory is actually cleaned when the server is rebooted?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question