I have a socket.io server that powers a multiplayer browser game. The separate ongoing matches are stored inside a single object in-memory on the server-side:
const matches = {};
When a player creates a match, I add a new unique key to this object for tracking information about that particular game. So when players make a move, I do something like this (simplified for example code):
matches[uniqueKeyForMatch] = newValidatedMatchState;
--where newValidatedMatchState
is a large tree of data describing this particular match. "Large" in this case meaning in total its various sub-dictionaries and sub-arrays contain several hundred individual pieces of numerical, boolean, and string data. Around 200-800 individual pieces of data like 5
or "some text"
, per match.
What I'm wondering is, if I have 100 concurrent matches, can the matches
object store that much data efficiently? From this question I see there is some limitation, but I'm not sure what else I could really do other than literally have two variables like matches1
and matches2
and split the data between them. Are there more efficient ways of doing this?