Reactive server var? Or something...?

I’m trying to make prototype of a collaboration game.
In the lobby you can join a game.
Currently I store all the currently happening stuff in the game in mongodb collections (Grapher).
But I was thinking if it would be better and more performant, to store the collaboration stuff temporarily in something else than the DB, and then just save the outcome/result in a collection when a round has ended?
The DB must require disk access, right?

Not all DB needs disk access. Some DB just store data in RAM, Redis for example.

But that isn’t the case with MongoDB, right?
Any concrete suggestions? Examples?

I don’t know how bad/good performant is. I think if your mongodb still can handle that then you don’t need any change.

there is something you can read:

@minhna: Thanks for that link - I hadn’t seen the inMemory storage option before. However, it looks like it would be tricky to set up, so you can still have persisted data somewhere in the replica set.

@stig: Using MongoDB as a global resource makes your use-case easy to build.


  • you have performance issues
  • you have confirmed it’s the database which is the bottleneck
  • you have optimised your database (indexes, denormalising, etc) as much as you can

then you could explore other options. However, to simplify the architecture it’s best to retain a global data store (Redis is a good choice, as @minhna has said).

Alternatively, you could manage intermediate game data/state in the server code - but beware if you run in a scale-out (multi-server) environment, as you will need to ensure that all players in a game are on the same server instance.

Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%. [Donald Knuth]

Make sure you’re in that 3%!