Firebase Cloud Functions min-instances 设置似乎被忽略了
Firebase Cloud Functions min-instances setting seems to be ignored
Firebase 已于 2021 年 9 月宣布,现在可以以某种方式配置其云功能自动缩放,以便始终 运行ning (https://firebase.google.com/docs/functions/manage-functions#min-max-instances) 一定数量的实例。
我试过设置它,但我无法让它工作:
起初我在 Google Cloud Console 中设置了最小实例数:Cloud Console Screenshot
这样做之后,我预计该云函数的一个实例会随时 运行。该函数的指标表明它的实例仍然缩小到 0:Cloud functions "Active Instances Metric"
所以对我来说,我的设置似乎在这里被忽略了。我错过了什么吗? Google Cloud Console 显示最小实例数已设置为 1,因此它似乎知道但忽略了它。此功能是否仅在某些地区可用?
我还尝试使用 Firebase SDK for Cloud Functions (https://www.npmjs.com/package/firebase-functions) 设置最小实例数。这给了我同样的结果,我的设置仍然被忽略。
根据 Documentation,活动实例指标显示当前正在处理请求的实例数。
如 Documentation 所述:
Cloud Functions scales by creating new instances of your function. Each of these instances can handle only one request at a time, so large spikes in request
volume often causes longer wait times as new instances are created to handle the demand.
Because functions are stateless, your function sometimes initializes the execution environment from scratch, which is called a cold start. Cold starts can take
significant amounts of time to complete, so we recommend setting a minimum number of Cloud Functions instances if your application is latency-sensitive.
您也可以参考 其中提到的
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.
Firebase 已于 2021 年 9 月宣布,现在可以以某种方式配置其云功能自动缩放,以便始终 运行ning (https://firebase.google.com/docs/functions/manage-functions#min-max-instances) 一定数量的实例。
我试过设置它,但我无法让它工作: 起初我在 Google Cloud Console 中设置了最小实例数:Cloud Console Screenshot 这样做之后,我预计该云函数的一个实例会随时 运行。该函数的指标表明它的实例仍然缩小到 0:Cloud functions "Active Instances Metric"
所以对我来说,我的设置似乎在这里被忽略了。我错过了什么吗? Google Cloud Console 显示最小实例数已设置为 1,因此它似乎知道但忽略了它。此功能是否仅在某些地区可用?
我还尝试使用 Firebase SDK for Cloud Functions (https://www.npmjs.com/package/firebase-functions) 设置最小实例数。这给了我同样的结果,我的设置仍然被忽略。
根据 Documentation,活动实例指标显示当前正在处理请求的实例数。
如 Documentation 所述:
Cloud Functions scales by creating new instances of your function. Each of these instances can handle only one request at a time, so large spikes in request volume often causes longer wait times as new instances are created to handle the demand.
Because functions are stateless, your function sometimes initializes the execution environment from scratch, which is called a cold start. Cold starts can take significant amounts of time to complete, so we recommend setting a minimum number of Cloud Functions instances if your application is latency-sensitive.
您也可以参考
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.