How many clients are connected to my firestore?

1,028

I will try to answer your questions:

How reads are considered when we see data on the console and how can I reduce my read requests? Basically there are 341 docs but it is showing more than 600 reads whenever I refresh my console.

Reads are considered depending on your how you query your Firestore database in addition to your access to this database from the console so using of the Firebase console will incur reads and even if you leave the console open to do other stuff, when new changes to database occured these changes will incur reads also, automatically.and any document read from the server is going to be billed. It doesn't matter where the read came from. The console should be included in that.

Check this official documentation under the "Manage data" title you can see there is a note : "Note: Read, write, and delete operations performed in the console count towards your Cloud Firestore usage."

Saying that if you think there is an issue with this, you can contact Firebase support directly to have more detailed answers.

However, If you check the free plan of Firebase you can see that you have 50K free reads per day.

A workaround that I found for this (thanks to Dependar Sethi)

  1. Bookmarking the Usage tab of the Firestore page. (So you basically 'Skip' the Data Tab)
  2. Adding a dummy collection in a certain way that ensures it is the first collection(alphabetically) which gets loaded by default on the Firestore page.

you can find his full solution here.

Also, you can optimise your queries however you want to retreive only the data that you want using where() method and pagination with Firebase

As you can see in the picture there are two types of document reads 'LOOKUP' and 'QUERY', what's the exact difference between them?

I guess there are no important difference between them but "QUERY" is getting the actual data(when you call data() method) while "LOOKUP" is getting a reference of these data(without calling data() method).

I am getting data from the firestore with a single instance and when I open my app the chart shows 1 active client which is cool but in the next 5 minutes, the number of active clients starts to increase.

For this question, considering the metrics that you are choosing in Stackdriver I can see 3 connected clients. and as per the decription of "connected client" metric:

The number of active connections. Each mobile client will have one connection. Each listener in admin SDK will be one connection. Sampled every 60 seconds. After sampling, data is not visible for up to 240 seconds.

So please check: how many mobiles are connected to this instance and how many listeners do you have in your app. The sum of all of them is the actual number of connected clients that you are seeing in Stackdriver.

Share:
1,028
Jagraj Singh
Author by

Jagraj Singh

Updated on December 14, 2022

Comments

  • Jagraj Singh
    Jagraj Singh over 1 year

    Metrics Explorer in my Stackdriver Dashboard I am working on a flutter app that fetches 341 documents from the firestore, after 2 days of analysis I found out that my read requests are increasing too much. So I made a chart on the stackdriver metrics explorer from which I get to know that my app is just reading 341 docs a single time, it's the firebase console which is increasing my reads.

    Now, comes to what are the questions that are bothering me,


    1)How reads are considered when we see data on the console and how can I reduce my read requests? Basically there are 341 docs but it is showing more than 600 reads whenever I refresh my console.


    2)As you can see in the picture there are two types of document reads 'LOOKUP' and 'QUERY', what's the exact difference between them?


    3)I am getting data from the firestore with a single instance and when I open my app the chart shows 1 active client which is cool but in the next 5 minutes, the number of active clients starts to increase.

    Can anybody please explain to me why this is happening?
    For the last question, I tried to disable all the service accounts and then again opened my app but got the same thing again.

     Firestore.instance.collection("Lectures").snapshots(includeMetadataChanges: true).listen((d){
      print(d.metadata.isFromCache);//prints false everytime 
      print(d.documents.length);// 341 
      print(d.documentChanges.length);//341 
    });
    

    This is the snippet I am using. When the app starts it runs only once.

  • Jagraj Singh
    Jagraj Singh over 4 years
    Thank you so much. When I was testing it , I was the only one who is using application , but in the stack drivers console it's showing me 5 clients connected. ( I disabled all other service accounts too)