is it possible to configure Cloud Scheduler to trigger multiple functions in one Job?

Viewed 739

I have 2 cloud functions that run every 5 minutes, currently using two different Cloud Scheduler Jobs, is it possible to configure Cloud Scheduler to run them both at the same time using only 1 job instead of 2.

1 Answers

You have several options. The 2 easiest are:

  • With Cloud Scheduler publish a message in PubSub instead of calling a Cloud Function. Then add 2 push subscription to PubSub to call your Cloud Functions. The message in entry in the topic is duplicated in each subscription (here 2) and thus the functions are called in parallel. Note: The PubSub message format isn't exactly the same as your own specific for Cloud Functions (if you have data to POST to your function) and you need to rework on this entry point part
  • With Cloud Scheduler you can call Workflows and in your workflow you can call task in parallel. I wrote an article on that this week

In both cases, you can't do this out of the box and you need to use a intermediary component to perform the fan out of the only one scheduling event.

Related