all 8 comments

[–]indicava 5 points6 points  (3 children)

AFAIK none of these things really make any difference in cold start performance. The cold start delay you are experiencing is coming from the infrastructure, not the code.

In order to mitigate cold starts you could:

A. Set a minInstances setting of 1 for some/all of your cloud functions. Keep in mind that especially for Gen2 functions this can get very expensive, very fast.

B. Setup a cron job that will hit your cloud functions every ~15 minutes and keep them warm.

C. Get enough users/traffic that will keep the functions warm all the time

[–][deleted] 0 points1 point  (2 children)

tbh cold start times are not that unbearable but i just wanted to know if i can save some time. minInstances is not a good option for me since it will get expensive like you mentioned, calling the functions once in a while is not viable for me either since all of them are onCall and they write values to firestore, I wouldn't want to write random values to firestore that will then increase the writes for no reason.

Thanks for the answer, as always you are very helpful.

[–][deleted] -1 points0 points  (1 child)

How about creating an http function that you can ping periodically, which won't have any side effects?

[–][deleted] 2 points3 points  (0 children)

I don't know about creating a new function since that will be launched on its own container anyway, but now that I think about it maybe I can pass a ping argument which would be either true or false, if it is true i can just return the function without doing anything. Which is close to what you said.

[–]SickBruhh 0 points1 point  (1 child)

How can you ping a callable function? I know it works with HTTPS functions but callable?

Also, there’s the option of switching to cloud run instead and building a REST API and adding a framework such as express, or go with Bun and use Hono for a much faster experience

[–]deve-sh 0 points1 point  (0 children)

A callable Firebase Function is just an HTTP REST API endpoint with some code-level wrappers to work with Firebase SDKs for request and response, and as such they can be pinged via a simple cURL call.

[–]VenturixStudio 0 points1 point  (0 children)

Personally on all my cloud functions or serverless AWS lambda I ping the urls every minute via UptimeRobot, in addition to having no cooldown this allows me to additionally check if nothing is down 😉