I have currently this structure.
Companies (20)
{
companyId: {
...comanyInfo
}
}
Users (500,000)
uid: {
...userInfo
}
User_Companies (500,000 * max(20))
uid: {
company1: true,
company2: true,
....
}
Company_Users (500,000 * max(20))
companyId: {
uid1: true,
uid2: true,
....
}
Company_POSTS (2000 posts per company)
{
companyId: {
postId: {
expired
...postInfo
}
}
}
User_Feed (For each user (500,000))
{
uid:
posId : {
like: true
}
}
Requirements:
User should get only the posts of the registered companies and user can register/unregister.
User shouldn't see posts he already like/unlike
So currently what I am doing, when users joins a company I copy the relevant posts(registered/ not expried) to the User_Feed.
So in the client I can fetch relevant users posts paged.
Now assume I have 4000k of posts I need to bring all the data to the server in order to copy this to USER_FEED.
it's a lot of data to bring and of course after some users joins to campaniles the server hangs.
another case if a company posts a new post it should be distributed to all the registered users 500,000 User_FEED.
which will require to fetch massive amount of data in order to fan-out it to firebase.
I am not sure how to solve this issues? even if I will fetch shallow 500,000 keys is a lot of data.