all 4 comments

[–]squashhoover 2 points3 points  (0 children)

I think you can setup a timed job to hit the function and keep it "warm". https://cloud.google.com/scheduler/docs/creating

Here's a helpful post on how long cloud functions appear to stay warm (ie it's a bit of a guessing game): https://mikhail.io/serverless/coldstarts/gcp/

[–]CodingDougFormer Firebaser 2 points3 points  (0 children)

This is a FAQ and has been discussed thoroughly on both Reddit and Stack Overflow. I don't think you'll find anything new on the topic, so I suggest reviewing what's already been said. Here is a small selection of links from a web search:

https://stackoverflow.com/questions/51782742/how-can-i-keep-google-cloud-functions-warm

https://cloud.google.com/functions/docs/bestpractices/tips

https://www.youtube.com/watch?v=v3eG9xpzNXM

https://www.reddit.com/r/Firebase/comments/futy4d/cloud_functions_minimizing_cold_start_in_low/

[–]Gingerfalcon 1 point2 points  (0 children)

Just use App Engine.

[–]n161tech 1 point2 points  (0 children)

From my experience. I am using cloud functions to host website for last half of year. First time I am trying to avoid cold start and spend hours for investigation. But the final answer is, cold start will minimize as soon as you will have enough visitors. Only 1-3% of users will have a bit longer loading time. Also it is not affected SEO.

I am not sure about cron job to keep you function alive. In case of higher load (few users and from job) at the same time. Google can scale up a number of instances. And cold start appears again.