MongoDB vs Redis for user sessions? MongoDB vs Redis for user sessions? mongodb mongodb

MongoDB vs Redis for user sessions?


Unfortunately, a definite answer will require a measurement using your setup because there are so many potential factors.

However, my guess is that the overhead of using two datastores outweighs any potential advantages because the reads should be incredibly fast on both DBs:

  • Since the sessions will be used often, the collection keeps pretty 'hot' so it will probably remain in RAM if any possible in MongoDB, too
  • Losing a session wouldn't be great, but it's not a disaster, so you can write to MongoDB without waiting for a journal commit (which is pretty much the same reliability redis has)
  • In either case, most time is (probably) spent on the network stack, and you have to go through that for both DBs

So, in a nutshell, I don't see any reasons why redis would be a lot faster in this case, but again, performance is often guesswork, especially when the details are unknown.