My WebCore App holds some user data in a FireStore DB and does not much more, than looking up a user. While the reported write counts are - as expected - about 10 per 24h, the reads are around 20.000.
I switched on the firebase internal logging, but until I get valid data, wanted to ask:
Any idea, where this amount of reads orginates from?
Can I somehow track the reads?
Any recommendation to monitor the traffic between a WebCore app and the firestore DB?
Thanks a lot for your support!
This is what firebase support answered:
Also, you may want to consider the following possibilities as the likely cause of your project's document reads:
- Unbound queries.- Every item in a query result counts as one document read. If the Firestore query is not given a limit, by default it will return every possible result that matches your query, even if the total number of results reaches the hundreds or thousands. Because of this possibility, it is considered best-practice to apply a reasonable limit on the number of results returned from Firestore.
- Frequent use of the get() method call.- Each get() request will generate a brand-new query on Firestore, even if the same request was made recently. If your app performs a get() request as part of an app event (ex: app resume, user scrolling, UI state change), it may be consuming more Firestore reads than actually necessary. In order to minimize the possibility of making redundant queries, consider using realtime listeners instead.
- Cloud Functions.- Any Firestore queries performed as part of a Cloud Function will count towards your overall usage. Make sure you don't have any unbound queries here.
- Security Rules.- Accessing document values as part of a rule evaluation also counts towards the total number of reads, which could be a major contributor to your overall usage depending on how frequently these rules are being used to evaluate access.
- Firebase Console.- When viewing Firestore collections through the Firebase Console, the first 300 documents in a collection are loaded automatically every time a different collection in the console is selected. When scrolling down a long list of documents, the next 300 documents will be loaded if there are more documents in the collection to display. It's generally recommended to be careful when it comes to usage through the Firebase Console.
- Failed Queries.- Every query attempt has a minimum cost of one read, which means queries that return empty results or fail your Security Rules can also contribute to overall usage. It's difficult for us to determine if these failed queries were well-intentioned or not, but if you suspect that your project is being hit with abusive queries with the purpose of racking up billing, do reach out to us as soon as possible.
If you're still unsure about where all of these document reads are coming from, you may also consider performing client-side logging in order to check how many document reads each client is consuming per request.
Without knowing how you use FireStore and/or our components in connection with this, it is hard to tell.
To begin with, do you use the FNC FireStore access component? The WEB Core FireStore dataset? Anything else?
I have two TWebFirestoreClientDatasets, each connects to an entity in the FireStore database.
I can think that when opening the dataset, a few requests are executed (to authenticate & to get the table/data structure).
So, first question is how many times do you open & close the dataset?
You can also monitor requests in the networking tab of your browser console.