Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Performance: How many children per node?

If a node has 100 million children, will there be a performance impact if I:

a) Query, but limit to 10 results

b) Watch one of the children only

I could split the data up into multiple parents, but in my case I will have a reference to the child so can directly look it up (which reduces the complexity). If there is an impact, what is the maximum number for each scenario before performance is degraded?

like image 451
CalM Avatar asked Sep 26 '16 21:09

CalM


People also ask

How many users can Firebase handle at a time?

*The Spark plan limit on simultaneous connections is 100. Simultaneous responses sent from a single database.

How do I speed up Firebase?

Clean up unused data Periodically remove any unused or duplicate data in your database. You can run backups to manually inspect your data or periodically back it up to a Google Cloud Storage bucket. Also consider hosting stored data through Cloud Storage for Firebase.

Can Firebase handle million users?

The limit you're referring to is the limit for the number of concurrently connected users to Firebase Realtime Database on the free Spark plan. Once you upgrade to a payment plan, your project will allow 200,000 simultaneously connected users.


1 Answers

If a node has that many children, accessing the node in any way is a recipe for problems. Accessing an individual child is never a problem.

Querying the node for a subset of its children still requires that the database consider each of those children. If you request the last 10 out of 100 million items, you're asking the database to consider 999,999,990 items that you're apparently not interested in.

It is impossible to say what the maximum is without a way more concrete description of the data size, ordering criteria, etc. But to be honest, even then the best you're likely to get is a value with a huge variance that is likely to change over time.

You best approach in Firebase (and most NoSQL solutions) is to model the data in a way that fits with how your app uses that data. So for example: if you need to show the latest 10 items to your users, store the (keys of) those latest 10 items in a separate list.

items
    -K........0
        title: "Firebase Performance: How many children per node?"
        body: "If a node has 100 million children, will there be a performance impact if I:..."
    -K........1
        title: "Firebase 3x method won't working in real device but worked in simulator swift 3.0"
        body: "Hi we are working with google firebase 3x version and we faced..."
    .
    .
    .
    -K999999998
    -K999999999
recent
    -K999999990: true
    -K999999991: true
    -K999999992: true
    -K999999993: true
    -K999999994: true
    -K999999995: true
    -K999999996: true
    -K999999997: true
    -K999999998: true
    -K999999999: true

I'm not sure if I got the right number of nines in there, but I hope you get the idea.

like image 151
Frank van Puffelen Avatar answered Sep 23 '22 03:09

Frank van Puffelen