简体   繁体   English

Express 应用程序是否始终在 Firebase Cloud Functions 中运行?

[英]Is an express app always running in Firebase Cloud Functions?

I am currently learning Firebase Cloud Functions and wanted to understand if the express app is always running, my assumption is that it is always running on the Firebase platform otherwise how does it handle a request?我目前正在学习 Firebase Cloud Functions,想了解 express 应用程序是否一直在运行,我的假设是它一直在 Firebase 平台上运行,否则它如何处理请求?

Your Express app on Cloud Functions runs in a container, and the default behavior is to spin down that container after there have not been any requests for a while (the exact period is undocumented). Cloud Functions 上的 Express 应用程序在一个容器中运行,默认行为是在一段时间内没有任何请求后停止该容器(确切的时间段未记录)。 Since you're only paying for the time it's actually actively processing requests, otherwise Cloud Functions would end up with lots of containers that nobody is paying for.由于您只需为它实际主动处理请求的时间付费,否则 Cloud Functions 最终会拥有大量无人为之付费的容器。

When a new request comes in when there is no container instance, or while all the existing containers are busy, Cloud Functions spins up a new container to process that request, which it then will also shut down when it's been inactive for a while.当没有容器实例或所有现有容器都很忙时收到新请求时,Cloud Functions 会启动一个新容器来处理该请求,然后它也会在闲置一段时间后关闭。

Since spinning up the container takes some time, you can configure Cloud Functions to keep a certain minimum number of containers active .由于启动容器需要一些时间,您可以配置 Cloud Functions 以保持一定数量的容器处于活动状态 But I'd usually recommend only looking at that when you're actively experiencing performance problems due to the startup time of new containers, as you'll pay (a lower amount) for each container that is kept active while not processing a request.但我通常建议只在您因新容器的启动时间而积极遇到性能问题时才查看它,因为您将为每个在不处理请求时保持活动状态的容器支付(较低的金额)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 从应用上下文调用的云函数始终为 null - Firebase Cloud Functions called from app context is always null 在 Firebase Cloud Functions 中使用 express 和 consign 进行路由 - Routing with express and consign in Firebase Cloud Functions 将 Firebase 托管重新路由到 Express Cloud Functions - Rerouting Firebase Hosting to Express Cloud Functions 避免客户端工作的 Firebase Cloud 功能总是值得的吗? - Firebase Cloud functions to avoid client side work is always worth? 如何在 firebase 云函数上正确使用 express-session - How to properly use express-session on firebase cloud functions 声明单独的 Firebase Cloud Functions 并仍然使用 Express.js - Declare separate Firebase Cloud Functions and still use Express.js Google Cloud Functions Firebase 错误 默认的 Firebase 应用已经存在 - Google Cloud Functions Firebase Error The default Firebase app already exists 运行 Firebase Cloud Functions 时使用哪个服务帐户? - Which service account is used when running Firebase Cloud Functions? Cloud Functions for Firebase 超时 - Cloud Functions for Firebase timeout Flutter/Firebase:管理功能是应用内功能还是云功能? - Flutter/Firebase: Admin features in-app or cloud functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM