How to limit instance count of firebase functions

Viewed 747

I use following firebase cli command to deploy my firebase functions

firebase deploy --only functions

How can I limit the number of instances for functions, when deployed like this? It looks like gcloud command has --max-instances option to limit instances, but couldn't find anything like this for firebase cli.

2 Answers

You can set the maxInstances when you write the function, using runWith and passing in RuntimeOptions

Something like this:

 functions
.runWith({maxInstances: 3})
.https.onCall(() => {});

There is currently no option on the Firebase CLI for this. Feel free to file a feature request with Firebase support. If such an option is added, it likely won't end up in the CLI, but rather the function builder interface, similar to how region and memory are set.

For now, you can use the Google Cloud console by finding your deployed function there and editing to to use the value you want.

Related