lundi 13 février 2017

NodeJS best performance possible when storing data when using web sockets

Vote count: 0

I'm developing a turn based game with NodeJS and Socket.io in which a lot of information is stored between turns.

I'm wondering what is the best approach to handle lets say, thousands of users.

Currently I'm using global variables to store everything related to a match in a "duels" global variable with the key being the dynamically created room:

duels[room].character_1 = character_1;
duels[room].character_opponent_1 = character_opponent_1;
duels[room].player_1_moves = {//really big object};
duels[room].player_2_moves = {//really big object};

I'm not sure if this is an optimal way to handle thousands of users. At least Memory wise.

I've seen 2 other options:

1st: Using Session variables to store the data, however this seems to me will take a lot of memory of the server(RAM), whats better global variables or sessions? Or are they both pretty bad?

2nd: I'm using MongoDB, is it a viable option to insert and retrieve information constantly in my database and have it stored there? I have a sense that if I send too much queries to my database it will crash.

Basically, at this point I have no idea where to store all this information without risking my servers performance. I'm open to any approach.

asked 14 secs ago

Let's block ads! (Why?)



NodeJS best performance possible when storing data when using web sockets

Aucun commentaire:

Enregistrer un commentaire