简体   繁体   中英

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?

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). 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.

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.

Since spinning up the container takes some time, you can configure Cloud Functions to keep a certain minimum number of containers active . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM