0

Is there a way to determine which API calls from a mobile app are driving firebase quota? There is a generic dashboard, that shows READS, WRITES,... per day, but nothing that I came across that shows what is driving those.

stan
  • 229
  • 3
  • 10

1 Answers1

1

Unfortunately, there are no dashboards that can give you what you're looking for.

Your best bet is to manually "log" all Firestore Write operations into your database, then compare the timestamps with other API's timestamps or Firebase Functions executions' timestamps, to determine the process that is doing the most work.

Here is an example here on SO (suggested to me by Firebase support), if I were to use this, I would turn it off after I'm done debugging. Because this solution itself is costly.

Another hint, when I had this exact same issue a few weeks ago, I looked at my code, and found out that queries which don't have a .limit(Number) were responsible for driving up costs. You may want to convert all your queries into limited queries because those can run wild and have no limit on their own if you don't impose one.

Another possible source for frequent write operations is the onWrite() events that can trigger every time a document is altered - and if they alter the document themselves, then you're just in a loop driving up cost infinitely. I try and stay away from those and use onCreate() + Scheduled functions instead.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    That is some great advice. Not the most elegant way firebase is providing, but still a way of reducing and managing loads. – stan Feb 26 '21 at 08:18