Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is firebase functions deployment extremly slow?

When I run the command "firebase deploy --only functions" it takes around 1 minute to deploy my function even if I didn't update my function.
Am I doing something wrong?
Could it be because of the node_modules folder in my functions folder?
Is function deployment in firebase just slow?
Console Log:

C:\Users\myUser\Desktop\myProject> firebase deploy --only functions

=== Deploying to 'myProject'...

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (36.96 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating Node.js 10 (Beta) function myFunction(europe-west1)...
i  scheduler: ensuring necessary APIs are enabled...
i  pubsub: ensuring necessary APIs are enabled...
+  scheduler: all necessary APIs are enabled
+  pubsub: all necessary APIs are enabled
i  functions: scheduler job firebase-schedule-myFunction-europe-west1 is up to date, no changes required
+  functions[myFunction(europe-west1)]: Successful update operation.

+  Deploy complete!

It usually gets stuck for 1 minute on this line:

i  functions: scheduler job firebase-schedule-svt-europe-west1 is up to date, no changes required
like image 878
yuval Avatar asked Apr 16 '20 21:04

yuval


People also ask

How fast are cloud functions Firebase?

The function itself takes about 400ms, so that's alright. But sometimes the functions take a very long time (around 8 seconds), while the entry was already added to the queue.

What is cold start in Firebase?

Note: Several of the recommendations in this document center around what is known as a cold start. Functions are stateless, and the execution environment is often initialized from scratch, which is called a cold start. Cold starts can take significant amounts of time to complete.

How many requests can handle a single cloud function in Firebase?

10 for single-document requests and query requests.


1 Answers

1-2 minutes is typical. Unlike some other FaaS providers, Cloud Functions is actually running npm install and building the node_modules in the cloud, which does take some time but also means you don't need to worry about cross-compiling native dependencies.

Cloud Functions doesn't know if you updated your function or not, so it does a fresh redeploy every time.

My recommendation is to ONLY update the functions you changed. You can do this with the following:

firebase deploy --only functions:specificFunctionName,functions:anotherFunctionName,etc

This should speed things up at least a little bit, but probably not a lot.

like image 89
Sandeep Dinesh Avatar answered Oct 19 '22 18:10

Sandeep Dinesh