0
votes

We are developing an app in dart wherein we need to fetch around more than 50K rows at once (doing it when app loads) and then data will be used in other sections of app for further calculations. We are using Firebase Realtime database and we are facing some serious performance issues.

Its currently taking somewhere around 40 seconds to load 50K rows(currently using free database version, not sure if that would the reason), but we have also observed that when multiple users uses the app, it starts to take around 1 minute 20 sec to load 50K rows and Peak goes to 100%.

Can you please suggest how can we improve performance in firebase realtime database ?

If I break the data in two collection but keep it in same JSON file, would that help ?

Can it be because we are using currently free database version for testing ?

We have tried creating indexes in "Rules" section on 1 Key field but that did not help much. Is there any way we can improve this ?

1
Hi Ammar- I checked that article but indexing did not help much, also we are going to monitor the performance using performance monitoring. - Neeraj Kaple
Applying load from a small number of users shouldn't affect the performance of a query very much. Without specific benchmarks, and understanding the quality of the network connection between your users and the database, it's really not possible to tell why things are slowing down. If the amount of data from your query grows, you can expect the query time to increase, as it simply has to move more data across the network. - Doug Stevenson
Thanks Doug for comment ! I am not expecting many user to hit the database at once, it will be around 15 users and each user will query once to do initial load of 40K to 50K rows in app. All 15 user will hit different node in JSON tree, if i split each collection(of 50K row) in separate database in single project, that might work but don't want to do that. - Neeraj Kaple

1 Answers

1
votes

Can it be because we are using currently free database version for testing?

All Firebase Realtime Database instances run on the same infrastructure. There is no difference based on the plan your project is on.

Can you please suggest how can we improve performance in firebase realtime database?

The best way to improve performance is to only load data that you're going to show to the user right away. In any client-side application it's unlikely that the user will look at 50K items, let alone look at them straight when the application starts.

If you need 50K items to show the initial data to the user, that typically means that you're aggregating that data in some way, and showing that aggregate to the user. Consider doing that aggregation when you write the data to the database, and store the aggregation result in the database. Then you can load just that result in each client, instead of having each client do its own aggregation.

For more data modeling tips, read NoSQL data modeling and watch Firebase for SQL developers. I'd also recommend watching Getting to know Cloud Firestore, which is for Cloud Firestore, but contains many great tips that apply to all NoSQL databases.