I have function that runs onSchedule
every minute (and creates a file in firestore)
and i want to run second function 45 seconds after the first one has been called. Is there any way to achieve this? I can’t use another onSchedule
cause they gonna missmatch after first run
I thought about using setTimeout()
but bill after something like that could be big (or im wrong?).
It sounds like you care about the exactness of the timing, which means that Cloud Functions are never going to be a great fit – as they are provisioned as needed. So you’ll always have a chance of it needing to provision a new instance for your request, and the execution will be delayed because of this cold start.
If you want to tightly control when the code runs, consider provisioning an always-on system (like a VM) and running a local process (e.g. with setInterval
or setTimeout
) on that. While recommending a specific always-on service is off-topic on Stack Overflow, there are tons of cheap always on cloud VM services, including a free e2-micro instance on Google Cloud.
3