Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Best / cheapest way to continuously run a script in GCP

Hi there,  sorry if I'm not posting in the right subforum. I'm looking for the right GCP product for my task, which is the following:

  • A TypeScript / NodeJS script has to run continuously, 24/7
  • At startup, the script fetches some data from a Firestore database
  • The script makes HTTPS calls to an external API every 30 seconds
  • If the response from the HTTPS calls contains a specific value, the script fires a FCM notification
  • The script doesn't need to handle (listen to) HTTP(S) calls
  • It's alright if the script stops from time to time, as long as a new instance starts to run right away
  • The script doesn't do any heavy computing

I'm basically looking for the GCP products that is best suited for my task, while also being as cheap as possible, of course.

Thanks 😊

0 4 1,203
4 REPLIES 4

How long does the script run for? If it's less than 30 seconds, I'd have a Node.js Cloud Function that gets triggered every 30 seconds by Cloud Scheduler, does its job and gets triggered again in the next 30 seconds and so on. 

The tasks the script does probably take ~5 seconds. I will look into Cloud Functions + Cloud Scheduler, thanks 🙂

Looks like Cloud Scheduler is not able to schedule functions more often than 1 minute. After some googling I believe I also need to use Cloud Tasks to overcome this.

jkg
Google Developer Expert
Google Developer Expert

Also like the scheduler idea. But if it’s not supporting the interval you need you could always use a VM in the free tier and setup a cron in there to execute the work?

Top Solution Authors