Answer the question
In order to leave comments, you need to log in
Node.js (as an option for storing temporary data)?
Good afternoon.
I want to analyze the question that interests me using the example of poker (since most people understand its essence and rules).
There is a Node+Express+Socket.io application + other auxiliary libraries . Here we admit in my application there is already a DB by means of which users are registered. The choice of rooms with a user rate is implemented using socket.io .
And here is the question itself, but is the process of the game itself (what cards are on the table now, what cards do the players have in their hands) is it better to write to the database or can it be done using arrays / objects? And why?
Answer the question
In order to leave comments, you need to log in
In a database (or a fast cache like Redis). There are several reasons:
Well, it’s clear that the training example doesn’t care about reliability and scalability, but why not do it right right away?
I would say NoSQL or memory.
This depends on the application, of course, but if the server crashes, then I think the session data should be reset to zero. Store in memory is always faster.
There is an option faster than the database - these are files written to the section with tmpfs.
When you boot the server, you create a temporary disk for N gigabytes.
You save everything you need there. And the fall of the node and the database server will not be terrible.
It is possible even with all the statics of the service, if we are talking about the web, it will not be worse.
But it is important to monitor memory overflow and OS stability.
Personally, I have a bunch of servers in maintenance with node apps where the uptime is greater than 365 days. The flight is normal.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question