Our goal is to set a minimum instance count for our firebase cloud function to be able to handle unexpected bursts of traffic. We've followed
However, the Active instances
count in the cloud function dashboard regularly falls below 3 (see image below). Does "active" in this metric only count instances which are being executed and doesn't count idling instances? Or does this actually mean that the minInstance
value is being ignored?
CodePudding user response:
As Cloud Functions is stateless it may initialize the execution environment from scratch which is called Cold Start. Cold Starts may take a significant amount of time and could increase the application latency. To reduce the number of Cold Starts, Cloud Functions for Firebase allows setting a minimum number of instances by specifying minInstances
by following this document. This will keep the specified number of instances ready or warm to serve the requests which will not go through cold starts.
Now in the Cloud Functions page of Google Cloud Console, the metrics Active Instances
means the number of instances that are currently serving the request as mentioned here.
Setting up minInstances
does not mean that there will always be that much number of Active Instances. Minimum instances are kept running idle (without CPU allocated), so are not counted in Active Instances
.