简体   繁体   中英

How to prevent throttling with Firestore when executing high amount of reads?

I am a Google blaze plan user and I have an express server containing a simple endpoint that just pulls from firestore. During high traffic hours, I can retrieve 5000+ simultaneous read requests which eventually throws this error below,

Error: 8 RESOURCE_EXHAUSTED: Quota exceeded.

After I wait a few minutes I am able to read the collection again.

Update: Unsure why the downvotes without any explainations.. but I also have a Mutex system which I think may be leading to hitting these limits. If fails to lock a document using transactions, it goes down an array of snapshots until a lock is given. If the array becomes empty, it does another read to firebase for another set of N documents, which is only 50 in my case.

So my question is, is there a limit on the amount of transactions or reads per second that we're allowed to do from a single connection (my express server)? I don't think it's stated anywhere in the documents.

It looks like you're reaching one of the read/write/transaction limits stated in this page .

Might be this one Maximum writes per second per database: 10,000 (up to 10 MiB per second) but I'm only guessing...

To answer your question, according to this link, the maximum concurrent connections for mobile/web clients per Firebase database is 1,000,000. Thus, your connections seem to not exceed the limits.

For the Blaze Plan project, the limit for Cloud Firestore Document Read is 50K/day , since free usage from Spark Plan is included in Blaze Plan. The limit is such, unless you have set any budget limit in your Billing account . The usage will be reset at midnight of PST. If you upgrade your plan to Flame Plan, the limit is 250K/day.

Here you may read about the official Cloud Firestore Quotas and limits, such as maximum document reads, maximum size for a document, that can be useful. Furthermore you may monitor your database usage and check your plan's limits from the “Usage” tab in the Firebase console. You can check usage over the current billing period, the last 30 days, or the last 24 hours.

Stackdriver Monitoring is also a practical tool for monitoring document reads/writes/deletes, active connections and snapshot listeners.

A good practice, if you want to avoid unexpected charges on your billing account, would be to create an alerting policy based on the Cloud Firestore metrics, as stated here.

Additionally, you can estimate and verify your monthly costs on the “Blaze Plan” by using this Blaze Plan calculator .

For anyone who runs into this issue in the future, please check your App Engine budget settings under "Application Settings". I set the daily spending limit to avoid unnecessary charges during testing and it slipped my mind. I increased the budget and the error is currently gone.

AWS usually sends me an email when my budget has been exceeded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM