Reputation: 1067
So for my application I am considering adding Redis. I am new to Redis and have not been able to come up with a good way to update the information I need to constantly update, so I was wondering if anyone could help.
In my app, I have a many to many relationship between posts and topics. Each post also has a score.
My first thought was to set up my Redis db so each topic was an ordered set of post_ids and each post_id in that ordered set was associated with that post's score. Posts are now each their own hash that associates their ID with the information about the post (score, user_id, url). I am periodically updating the score of that post, which brings me to my problem. When I update the score of that post, according to the setup I have now, I need to go and find every topic that post is associated with and update the score for the post_id in that topic's ordered set. This does not seem like the best solution if I were to scale the app to millions of posts and millions of topics.
Is there a better setup for my Redis db that I am not seeing or should I just stick with my SQL db?
Upvotes: 1
Views: 1543
Reputation: 49962
The design is solid for storing posts and keeping track of posts per topic by score.
In terms of scalability, I don't see a problem with millions of topics and posts but you'd be safer doing some back-of-the-napkin math to have a sense of stuff like the throughout you'll need and amount of memory required. Also, from the looks of it out looks that you can easily use two databases - one for posts and one for topics - to better handle potential load.
Lastly, no - if Redis isn't enough, I don't see how you'll pull this off with decent performance and scale with a SQL database.
Upvotes: 2