what is the most efficient way of creating a feeds system with node, redis and socket.io
I am trying to create an activity feed for each user in my application. i want to use redis to store two sets per user. 1 for storing the ids of his followers and 2 for storing the ids of the activities from every user he is following(his feeds).
so what i want to do is when a user as a post/creates an activity i want to push the id of that post/created activity to the the list of every user whose id is in the set containing the users followers.
i am assuming i would have to loop through the 'followers set' and for each one, add the post/activity id to each of the followers 'feed set', and emit an event with socket.io for that user( newfeedevent ) . i noticed that if about 10 or 20 people having about 100000 followers should create an activity about the same time, it would take about 6 minutes or more to update each of the feeds of the followers of the 10th or 20th person.
i want to believe there is a more efficient and faster way of doing this, especially if the 'followers set' contains 1000000 records.
e.g
// to add followers to user with id of 1
sadd user.1.followers 4 90 3 48 8 2 45
//to add an activity with id 200 to user 1 feed
sadd user.1.feeds 200
// to get all user with id 1 followers
smemebers user.1.followers
//to get the feed of user 1
smembers user.1.feeds
Please or to participate in this conversation.