0

I know that redis is a different architecture from mongodb. From reading other posts here and on other sites, it looks like redis is good for scenarios where you don't have as much data... Mongo seems to shine when dealing with very large amounts of data. I also know that Mongo is schema-less.

I need to build a solution that will allow me to:

  • have a "master" database that will be persisted to disk
  • have n number of "slave" databases..that will only be run from RAM
  • i like how mongo stores json documents - not sure if i can accomplish something similar in redis.
  • if any node goes off line (including the master node), the rest of the participants "just keep on working". Some slaves will be running on parts of the network that has very high latency issues.

I'm currently reading over the both the Mongo and Redis replication documentation but haven't run into anything that describes this particular use case. Any insights would be appreciated.

EDIT 1

I will need to be able to extract data based on values. So let's say for example, I create the following data in Redis:

127.0.0.1:6379> set users:leto '{"name": "leto", "planet": "dune", "likes": ["spice"]}'
OK
127.0.0.1:6379> get users:leto
"{\"name\": \"leto\", \"planet\": \"dune\", \"likes\": [\"spice\"]}"

At times, I will need to extract data based on values... so finding all users that have "dune" set as the "planet" value. Is this type of querying possible in redis?

dot
  • 14,928
  • 41
  • 110
  • 218
  • I think this article will really shed a lot of light for those contemplating how / where to use redis: http://oldblog.antirez.com/post/take-advantage-of-redis-adding-it-to-your-stack.html – dot Aug 22 '16 at 14:57

1 Answers1

0

you can not really compare Redis and MongoDB.

Redis is like MemCache but can store on disk. Redis store primitive data like string, list of string... not an object. If you want store object, you must stringify this before.

You cannot request on data, just on key name.

If you dont need persiste data on disk, Redis can also do that.

If you want only one master, but with replication on slave and if master down, use slave, you must use Redis with Sentinel.

To help you, I need know type of data you need store ? Can you support data partition ? Do you need rollback (I think no) ? What is size of totally data store on node ?

A good use case of Redis is in CQRS. Redis can be use for R.

Regards,

EDIT:

At times, I will need to extract data based on values... so finding all users that have "dune" set as the "planet" value. Is this type of querying possible in redis?

No you can't querying.

If you have hudge insert data use Cassandra.

bubulemaster
  • 221
  • 2
  • 8
  • I didn't realize you can't extract data based on value... Please see Edit 1 – dot Aug 22 '16 at 14:37
  • Thanks for the tip re: CQRS. I read this article:http://martinfowler.com/bliki/CQRS.html ... and after reading it... I don't I need separate models for reading /writing data. So maybe redis is a bad choice for me – dot Aug 22 '16 at 14:46
  • CQRS is just an example. Actually, I use Redis to store JSON format and is not really good case. – bubulemaster Aug 22 '16 at 14:55
  • are you using hashes to store your data? From my limited reading this morning, it looks like you can have some pretty good success handling/querying "json-like" data in redis if you use hashes – dot Aug 22 '16 at 15:16
  • Non, I don't use addon like https://github.com/mattsta/krmt/blob/master/json/json.c. Maybe is good solution. – bubulemaster Aug 22 '16 at 15:47
  • No i'm not referring to add ons. I'm talking about creating secondary pseudo indexes. http://openmymind.net/redis.pdf – dot Aug 22 '16 at 15:48
  • Ok, sorry. No, cause I prefere use MongoDb than Redis+Index. I'm not really test hash in redis, but I think is good. When database is big, Redis is not necessarily good choice, cause you need many RAM or many cluster with partition. – bubulemaster Aug 23 '16 at 09:18