I currently have a firebase project with multiple cloud functions defined. Each of these functions resides in its own folder with two files: index.js and package.json. As far as I've been able to tell, it is possible to import all of these functions into the index.js file within the default functions folder and export them. However, this approach leads to the deployment of all the functions on the same instance. Is there a way to force them to deploy on their own instances? Thank you!
Asked
Active
Viewed 731 times
1 Answers
5
Firebase parses the index.js
and creates separate containers for each exported function.
So each exported function in Cloud Functions runs on its own container instance(s) already. Separately exported functions will never run on the same container instance.

Frank van Puffelen
- 565,676
- 79
- 828
- 807
-
If I examine the source for the deployed functions on the google cloud UI, it shows functions/index.js which led me to believe that all functions are deployed on each instance. Does this make sense? – Patrick Oshea Jun 04 '21 at 15:02
-
1The code for all functions is deployed on each, but they run on separate instances. This is one of the differences with Cloud Run, where multiple functions **can** be on the same instance. – Frank van Puffelen Jun 04 '21 at 15:20
-
1@PatrickOshea As an addendum to this answer, check out the [`better-firebase-functions`](https://www.npmjs.com/package/better-firebase-functions) package, this [post on the Firebase Dev Blog](https://medium.com/firebase-developers/9261ee8450f0) and [this thread](https://stackoverflow.com/q/66813496/3068190) (for abstracting express routes). – samthecodingman Jun 04 '21 at 17:46