Sign In Register

How can we help you today?

Start a new topic
Answered

Redis persistence? Mongodb best practice

Hi,


I'm considering if I should Mongodb or Redis for the storage of game state.

1. I read that Redis is faster because it works in memory only. So is it possible my data would be lost somehow? Is it safe to only use Redis?

2. Can I expore data in Redis in NoSQL tab?

3. What is the best practice to use Mongodb and Redis?


Thanks a lot!

Jo


Best Answer

Hi Jo, 


In order to view your Redis data you can build a custom screen in the 'Manage' section.


The answer to your question depends on two things: how you want to query the data and the amount of data you want to store.


One of the fundamental differences between Mongo and Redis is that Mongo is a document store while Redis is a key-value store. A general rule of thumb is that you should use Mongo when you need database capabilities and Redis when you want to solve problems that could be solved by using classical data structures such as lists, hash tables, sets.


For your particular problem I would suggest using Mongo and here's why:


- In order to take advantage of the full potential of Redis you can only query the data based on an ID. You will have to define the structure of your ID before you launch your game and you cannot change it without adding some extra logic to convert from the previous IDs to the new IDs. Therefore, if you think that you might want more flexibility in building your queries, Mongo is the better choice.


- Because Redis works in memory, you need to asses how much data you will need to store in order to avoid bringing your own game down. How much data will the game state contain? How many players do you think you will have? 


So: I believe you're better off using a Mongo collection and creating the appropriate indexes on it.


Alex







1 person has this question
1 Comment

Answer

Hi Jo, 


In order to view your Redis data you can build a custom screen in the 'Manage' section.


The answer to your question depends on two things: how you want to query the data and the amount of data you want to store.


One of the fundamental differences between Mongo and Redis is that Mongo is a document store while Redis is a key-value store. A general rule of thumb is that you should use Mongo when you need database capabilities and Redis when you want to solve problems that could be solved by using classical data structures such as lists, hash tables, sets.


For your particular problem I would suggest using Mongo and here's why:


- In order to take advantage of the full potential of Redis you can only query the data based on an ID. You will have to define the structure of your ID before you launch your game and you cannot change it without adding some extra logic to convert from the previous IDs to the new IDs. Therefore, if you think that you might want more flexibility in building your queries, Mongo is the better choice.


- Because Redis works in memory, you need to asses how much data you will need to store in order to avoid bringing your own game down. How much data will the game state contain? How many players do you think you will have? 


So: I believe you're better off using a Mongo collection and creating the appropriate indexes on it.


Alex






Login to post a comment