Requirements:
- Users can register to company & unsubscribe freely.
- Users should get only the posts of companies they are registered to.
- Users shouldn't see posts they already liked/disliked
Currently, what we are doing is, when a user joins a company, we copy the relevant posts to the user User_Feed
, and the client fetches the posts.
Now assume we have 40K posts & 500K users. Each user that joins a company, we need to copy 40K of data to the user feed. Or when a company posts a new post, we need to build a huge fan-out object to pass to 500K USER_FEED
s.
This is not scalable.
David East in his post states that the fan-out technique supports millions of records, but even in his example, how can he handle 1M followers?
We feel like we're going about it the wrong way.
Is there a better solution to our problem?
We currently have the following structure:
Companies(~20 companies)
{
companyId: {
...comanyInfo
}
}
Users (~500K users)
uid: {
...userInfo
}
User_Companies (500k * max(20 companies))
uid: {
company1: true,
company2: true,
....
}
Company_Users (20 * max(500K users))
companyId: {
uid1: true,
uid2: true,
....
}
Company_POSTS (2K posts/company)
{
companyId: {
postId: {
...postInfo
}
}
}
User_Feed (For each user (500K))
{
uid:
posId : {
like: true
}
}
This post is also opened in Firebase Google Group