Redis vs. MongoDB Performance

November 18th 2013, 12:20 pmCategory:Web 7 comments

Maciej January 2nd 2014, 2:27 am

What 'save' settings were used for redis?

Alex Schleber January 10th 2014, 4:09 pm

Hmmm... not sure about this, just going dirt simple off of the Mongo shell I get the following for 50k writes (~ 2,000 millis):

NOTE: not even sure what the Write Concern is coming from the shell, will test out in Node next with {w:1} or {w:0}...

> ts1=new Date(); for(var i=0; i<50000; ++i) { db.tss2.insert({a:99}); } ts2=new Date()
> took = ts2 - ts1

> ts1=new Date(); for(var i=0; i<50000; ++i) { db.tss2.insert({b:"abcdefgh"}); } ts2=new Date()
> took = ts2 - ts1

> db.tss2.stats()
"ns" : "test.tss2",
"count" : 100000,
"size" : 3800020,
"avgObjSize" : 38.0002,
"storageSize" : 5591040,
"indexSizes" : {
"_id_" : 3262224

Chrys August 1st 2014, 12:52 pm

In the latest releases of drivers, Mongo has tried to make all drivers uniform, I believe most of them use WriteConcern.ACKNOWLEDGED {w:1} by default now. You could use w:0, UNACKNOWLEDGED to see if you get similar results, however this would be un-reflective of most production cases where it is usually preferable to have w:1+ and/or JOURNALED entries as well. In that regards, I believe redis still beats Mongo.

Ganesh October 28th 2014, 3:19 am

For larger entries, Redis has remarkable superiority over mongo. What about in case of larger data to read and write??

Bigous January 20th 2015, 6:54 am

@Alex Schleber
In your example you are mesuring only the time that NodeJS spend to put async calls on the queue, and not the time that mongo spent to run those calls.

Serg April 12th 2015, 1:34 am

For very large concurrent read and write it is actually opposite according to my tests.

ghost November 3rd 2015, 11:51 am

In redis benchmark script you have client = redis.createClient(); in function redisRead. Create new instance get more additionally time and memory. Hidden operation:
1. delete prev instance client
2. free memory used thru that instance
3. realocated memory for new instance
4. create new instance and assing it to variable
5. allocated memory for new instance

If you remove additionally assign operation you see that you benchmark show that Redis is faster that MongoDB

Leave a Comment