Firebase Scalability Limit

后端 未结 1 738
轻奢々
轻奢々 2021-01-04 18:21

This post says that FireBase will have an issue coming when an individual node begins to have 1-10+ million children. How should one handle Users in an app if we have more

相关标签:
1条回答
  • 2021-01-04 19:14

    Firebase is not ideal for processing long lists of items. The problem with these long lists is not so much storing the data as it is accessing the data.

    Whenever you access the list (e.g. ref.child('users').on(...) Firebase has to consider all items in that list on the server; even when you are only downloading a few users (.limitToLast(10)), it has to consider each user.

    But as long as you never try to access the list, you can store as many users under there as you want. But that means that you always access them directly, e.g. ref.child('users').child(auth.uid).on(....

    This limits the use-cases you can implement, so typically developers create sublists of users by how they need to use them. For example if each user is keeping a list of friends, you could keep those like ref.child('users_friends').child(auth.id).on(... and look each of them up with ref.child('users').child(auth.uid) again. That way, you're only reading a small list of users and then loading each of those users directly.

    0 讨论(0)
提交回复
热议问题