Search code examples
firebasecrongoogle-cloud-functionsscheduled-tasks

Cron every 10 seconds (Firebase funtions)


I need to run a function in firebase every 10 seconds (I call an external api and process data).

With a normal cron I cant because it is limited to maximum once a minute. Using a setTimeOut is also not convenient since Functions charges per second of use.

My only idea so far is to use Cloud Tasks. But I don't know if it is the most convenient to use this tool for my purpose.


Solution

  • On Google Cloud Platform, Cloud Tasks is almost certainly the best/only way to get this job done without using other products in a way that they weren't intended. Cloud Functions is not good for the reasons you mentioned. With Cloud Tasks, you will need to have the prior task schedule the next task upon completion, as they will not repeat themselves automatically like cron.