Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Functions - You have exceeded your deployment quota

I have a Firebase Functions project with 70+ functions. It runs on Node 8.

After 5-7 full deployments I am getting an error:

You have exceeded your deployment quota, please deploy your functions in batches by using the --only flag, and wait a few minutes before deploying again. Go to https://firebase.google.com/docs/cli/#deploy_specific_functions to learn more

It is not clear what is the reason for that? Which limit I have reached? When quota will renew?

Deployment is not working after a few minutes.

like image 869
Dariusz Bacinski Avatar asked Jul 02 '19 07:07

Dariusz Bacinski


People also ask

How many times can I deploy to Firebase?

So 12000/70 gives around 170 functions deploys per day. On Quotas admin page (second link) you can ask to increase any quota with Edit Quota option. 36000 sec build time is available without any additional approvals which in my case increased individual functions deploys number to 500+ per day.

How many requests can a single cloud function handle?

Several concurrent requests case Most of time, a service handles several requests in the same time. Cloud Run has the capability to handle up to 80 concurrent requests with the same instance. At the opposite, Cloud Functions create as many instances as the concurrent requests.


2 Answers

I have asked for help on Firebase Community slack and now I understand what has happened. Thanks, @katowulf.

Quotas are described here: https://firebase.google.com/docs/functions/quotas#quota_limits_for_firebase_cli_deployment

We have 3 quotas related to deployment which are:

  1. API calls (READ) - 1 call per deployment, no matter how many functions
  2. API calls (WRITE) - 1 call per function
  3. Max build time - A few minutes per function depending on size

To see which one you have hit you can go to quotas admin: https://console.cloud.google.com/projectselector2/projectselector/iam-admin/quotas?service=cloudfunctions.googleapis.com&usage=ALL&supportedpurview=project

In my case, I have hit quota 3. Max build time which is limited to 12000 seconds per day (by default). After some experiments, I have noticed that one function deploy adds around ~70 sec to build time (might be a different number in your case!). So 12000/70 gives around 170 functions deploys per day.

On Quotas admin page (second link) you can ask to increase any quota with Edit Quota option. 36000 sec build time is available without any additional approvals which in my case increased individual functions deploys number to 500+ per day.

Quotas Admin

A quota was reset to 0 around 0:00 UTC-07:00 and my functions are deployed to us-central1. So day seems to have a fixed time slot (it is NOT last 24h moving window).

For bigger projects, you should not deploy the whole project all at once, but just individual functions like described in a link https://firebase.google.com/docs/cli/#deploy_specific_functions

like image 128
Dariusz Bacinski Avatar answered Sep 25 '22 12:09

Dariusz Bacinski


Your functions are 70+ so deploying it 5-7 times in a short span will exceed one of the limits mentioned here: https://firebase.google.com/docs/cli/#deployment_quotas

For each function that the Firebase CLI deploys, these types of rate and time limits are affected:

API calls (READ) - 1 call per deployment, no matter how many functions
    Limit: 5000 per 100 seconds
API calls (WRITE) - 1 call per function
    Limit: 80 per 100 seconds
Max build time - A few minutes per function depending on size
    Limit: 120 minutes per day

Here is an example which may relates to your error: https://firebase.google.com/docs/cli/#deployment_quotas

It's possible (though unlikely) that you might exceed a quota that limits the rate or volume of your Firebase deployment operations. For example, when deploying very large numbers of functions, you might receive an HTTP 429 Quota error message. To solve such issues, try using partial deployment or requesting quota increases for specific Firebase services. For example, the quota called Write requests per 100 seconds per user might help to resolve the Cloud Functions 429 error cited above.

What you can do is create a script which will call deploy for each function, if you want to deploy every function. This will make sure that you don't exceed the limits in your production.

In development you know which functions will have changes based on code changes, so you can only deploy modified functions and do your testing.

like image 33
Umar Hussain Avatar answered Sep 26 '22 12:09

Umar Hussain