Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understand where the bandwidth usage is coming from in Firebase database

My app is growing in terms of bandwidth usage with Firebase database and I am trying to optimize my queries to use less bandwidth (thus reduce cost) but I am doing this quite blindly because there are no statistics about my database usage (I can't know what queries take the most bandwidth).

Is there somehow a way to know which queries are taking a lot of bandwidth? How do you go about optimizing usage with Firebase database?

Edit:

I have a chat website, and I use observers such as messagesRef.child(conversationID).limitToLast(25).on('child_‌​added'... conversationsRef.child(conversationID).('participants').on('value'...

like image 733
Dan P. Avatar asked Sep 12 '16 14:09

Dan P.


2 Answers

The Firebase Profiler saved my life for this. https://firebase.google.com/docs/database/usage/profile

Was able to pinpoint exactly what reference (including children) was hogging the bandwidth, which made it much easier to figure out which part of the code is problematic.

like image 105
Dan P. Avatar answered Oct 16 '22 14:10

Dan P.


there's no query tuning tools, if that's what you're looking for. you could build in simple time logging to capture just before and after queries are issued, log that data, and harvest it from client to narrow down to the most poorly performing ones.

hard to help without seeing the actual queries or the data model.

like image 24
ZagNut Avatar answered Oct 16 '22 14:10

ZagNut