I am aiming to build a scalable infrastructure (for fun) for a user posting system where timelines exist, such as a feed system. Feeds would include posts of a users followings.
Anyways, the current approach is this.
1.
UserA
UserA
follows
UserB
UserB
2. Save the follows relationship in the DB 3. Create a redis list
<userBiD-followers> -> [userAid, ...]
<userBiD-followers> -> [userAid, ...]
4. UserB creates a post 5. Save that post into the DB 6. Push the <postId> into their Redis list
7. I essentially iterate over UserB followings, and push UserBs new post into all of their timelines. (fan-out)
Is this the right approach? Anything better I can do?
Another question of mine is, is it much faster to retrieve a redis list of postIds, and pass them into Prisma to get the actual posts than doing queries with just Prisma?