0
votes

I have written a code to write data to custom metrics cloud monitoring - google app engine.

For that i am storing the data for some amount of time say: 15min into datastore and then a cron job runs and gets the data from there and plots the data on the cloud monitoring dashboard.

Now my problem is : while fetching huge data to plot from the datastore the cron job may timeout. Also i wanted to know what happens when cron job fails ? Also Can it fail if the number of records is high ? if it can, what alternates could we do. Safely how many records cron could process in 10 min timeout duration.

Please let me know if any other info is needed.

Thanks!

1

1 Answers

1
votes
  1. You can run your cron job on an instance with basic or manual scaling. Then it can run for as long as you need it.

  2. Cron job is not re-tried. You need to implement this mechanism yourself.

  3. A better option is to use deferred tasks. Your cron job should create as many tasks to process data as necessary and add them to the queue. In this case you don't have to redo the whole job - or remember a spot from which to resume, because tasks are automatically retried if they fail.

Note that with tasks you may not need to create basic/manual scaling instances if each task takes less than 10 minutes to execute.

NB: If possible, it's better to create a large number of tasks that execute quickly as opposed to one or few tasks that take minutes. This way you minimize wasted resources if a task fails, and have smaller impact on other processes running on the same instance.