3

I'm using MongoLab as an hosted MongoDB, does it make sense to cache the responses with Memcache or Redis ?

I read that its common to use Redis as cache, but on the other hand I read that MongoDB and Redis might have similar performance if MongoDB isn't paged.

3
  • 1
    I agree with @kokx that you shouldn't jump to caching unless you're sure you need it. If you do though, Redis is much more powerful tool than memcached with persistence and additional datatypes. You can efficiently cache collections or hashes in Redis whereas memcached can't. Redis performance keeps up with memcached on traditional key/value storage too. Jan 7, 2013 at 7:23
  • 1
    It sounds like you're trying to solve the wrong problem. If MongoDB is running slowly, you should fix MongoDB rather than adding another layer of complexity to your stack.
    – Tyson
    Jan 9, 2013 at 19:12
  • I'm still in development so I MongoDB isn't running slowly yet, I asked the question to understand If I should look into some sort of caching Jan 9, 2013 at 22:30

2 Answers 2

8

It all depends on your application. Database systems like MongoDB or SQL databases actually aren't very slow. When the load on your application isn't very high, caching will probably not improve that much.

You should use caching when its right. When access to your database (or any other resource) is slow. So first you should determine that. And if that is the case, you can go ahead and use either memcached or Redis for caching (or any other tool). It will take of some of the load on your database.

1
  • +1 don't implement caches for the sake of implementing caches; do it when you feel something is slow and you feel an additional caching layer is gonna help speed it up.
    – Mahn
    Jan 7, 2013 at 22:02
1

I studied on this sometime back and what i found was Mongodb's caching is good enough and you don't need memcache or redis.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.