Tuesday, 18 February 2020

Temporary storage on the server

I’m building a game with Node as the backend and I would like to implement a system that will match players based on game parameters they select and will store them in a queue-like structure in case they can’t be matched with these parameters. Once a new player joins, iterate through the queue, and if there’s a match, remove that user from the queue.At the moment I’m just mimicking that system with a basic array but I’m thinking about deploying to production and I know that it’s best practice to keep the server stateless if I ever want to scale and run multiple instances.I’d also prefer avoid using the database for this as there’s no real value in storing the info, as users will be deleted from the structure once they’re matched, or if after a few seconds they can’t get any match with the criteria they picked. Finally I’d like to avoid hitting the database unnecessarily, to reduce costs obviouslyWhat are the current and most recommended solutions to my problem?I’ve heard Redis could be used as an in-memory database but I’m wondering whether the key:value format suits my problem and will let me easily iterate over the stored players, who are waiting to be matched.Thanks!

Submitted February 18, 2020 at 06:15PM by LongHalloween11

No comments:

Post a Comment