2

After some research online, I could not find much benchmark comparison between the two. I did find one redis vs mongodb: (How much faster is Redis than mongoDB?).

According to my following extremely unscientific test, running two simple non-equal code in rails, I'm guessing the writes are about the same, but the redis is about 2x faster in reads. Not as big a speed advantage as I expected, considering my views are normally 50ms~150ms.

My question is, are there other benchmarks out there that could give me a "rough" idea about the two? With convention configurations in both, maybe even test it against a heroku basic dyno and its postgres service? Thank you!

##NOTICE: #follow is implemented with Redis. #public is just a postgres ActiveRecord property.
[93] pry(main)> Benchmark.measure{ 100.times { c.public = !c.public; c.save; c.public = !c.public; c.save}}
=> #<Benchmark::Tms:0x007faeb3c814f0
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.743117,
 @stime=0.03000000000000025,
 @total=0.6000000000000005,
 @utime=0.5700000000000003>
[94] pry(main)> Benchmark.measure{ 100.times { u.unfollow! u2; u.follow! u2 }}
=> #<Benchmark::Tms:0x007faeb1409c20
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.988483,
 @stime=0.14000000000000057,
 @total=0.8800000000000026,
 @utime=0.740000000000002>
[95] pry(main)> Benchmark.measure{ 100.times { u.follows? u2 }}
=> #<Benchmark::Tms:0x007faeb2f22ea8
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.045072,
 @stime=0.009999999999999787,
 @total=0.06000000000000405,
 @utime=0.05000000000000426>
[96] pry(main)> Benchmark.measure{ 100.times { Course.first.public? }}
=> #<Benchmark::Tms:0x007faeac97b8c0
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.11811,
 @stime=0.0,
 @total=0.09000000000000341,
 @utime=0.09000000000000341>
Community
  • 1
  • 1
randomor
  • 5,329
  • 4
  • 46
  • 68

1 Answers1

-1

Redis is a key-value store database, Postgres is a RDBMS. Key-value database allows data to be stored schema-less but not Relational database.

Both the approaches have their own pros and cons. For further reading, you can view this existing stackoverflow post.

Community
  • 1
  • 1
Nanda
  • 464
  • 4
  • 6