Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account following/followers scalability issue #40

Open
techcoderx opened this issue Jul 6, 2020 · 2 comments
Open

Account following/followers scalability issue #40

techcoderx opened this issue Jul 6, 2020 · 2 comments
Assignees
Labels
bug Something isn't working discussion

Comments

@techcoderx
Copy link
Collaborator

techcoderx commented Jul 6, 2020

Currently, the full list of accounts followed and followers are stored in a single document in accounts collection. As MongoDB limits document sizes to 16MB, this could become an issue when a channel has millions of subscribers, where storing the entire list of account names will exceed this limit.

Also, the /account/:name API returns the full account details, which is all the data stored in the document. If the full list of accounts following/followers can be returned, the response could be several gigabytes in size for a large channel.

@skzap
Copy link
Member

skzap commented Jul 10, 2020

@techcoderx Thank you for adding this issue.

In short term, we definitely need to add some protection in transactions verification to avoid going over 16MB in a single document (if JSON.stringify(new_doc).length > 16000000 -> invalid transaction), because it clearly would cause a node crash. Even though even if all accounts followed a single account right now, we would still be far from it, it's clearly possible in the future.

In practise, this means there will be a hard-cap to how many followers you can get (probably around 1-2M). In order to lift this limit in the future I suppose there are two solutions:

1- Remove the 'followers' field on accounts data, and let the API nodes manage it based on the 'follows' field alone which has a max length of 2000. This solution has a negative side though, as 100% of accounts would need to be loaded in memory when the API nodes start.

2- Remove both followers and follows fields in account data. And instead use a new collection, and then each follow will become a single document, lifting the limit completely (we could even imagine getting rid of the maxFollows per account)

Also I'm pretty sure the same scalability issue generally applies to all existing arrays in documents. So it also applies to votes on contents and custom keys on accounts. So probably creating a more generic 'list' collection is better. Then we can use it for future features too (like the 'verified content creator' badge, or playlists).

@skzap skzap added bug Something isn't working discussion labels Jul 10, 2020
@skzap skzap self-assigned this Jul 10, 2020
@hightouch67
Copy link
Contributor

I definitely agree with the solution number 2. This would improve the scalability of avalon and as you said permit to get rid of many limits. Followers and followings are also not necessarily loaded for an user in most of cases/pages and now each account call is clearly getting them. And it probably doesn't need for those collection to be loaded in the nodes cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion
Projects
None yet
Development

No branches or pull requests

3 participants