Should I Use Redis for Session Management When Storing User Data in Postgres?

0
3
Asked By TechieNinja42 On

I'm considering whether to store sessions in a separate Redis store instead of just keeping everything in Postgres. If I go with Redis, I would need to look up the session cookie there to get the user ID, and then run a separate query in Postgres to retrieve the user data. Doesn't this approach seem less efficient than running a single query with a join?

2 Answers

Answered By CodingWizard77 On

Using Redis can really help with scaling your sessions across multiple nodes, especially when traffic picks up. It's like having a turbo boost for session lookups, which makes it super fast when you're dealing with high requests per second (RPS). If you preload some common user data when they log in, it can save time in the long run.

Answered By DevGuru99 On

You're right that if you're already making calls to Postgres for user data, adding Redis might feel like an extra step. However, splitting sessions into Redis is mostly about speed and handling larger scales. Redis shines when there are many concurrent users or when sessions are short-lived. For smaller apps or less traffic, sticking with Postgres for sessions can be simpler and just as effective.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.