What is the current maximum timeout for a GCP Cloud Run app invoked by Cloud Scheduler

Viewed 1249

I am looking at using Cloud Scheduler to trigger daily execution of a python app on Cloud Run. The app pulls data from a third party API and inserts it into BigQuery. The only issue is, that according to many articles I have read, Cloud Run has a 15 minute execution time limit, which is potentially too short.

Looking at the Cloud Run docs though: https://cloud.google.com/run/quotas#cloud_run_limits it seems to suggest that the maximum execution is 60 minutes.

Which is correct? Can cloud run in fact run processes up to 60 minutes? and am I likely to have any issues using Cloud Schedular to trigger Cloud run if the process takes longer than 30 minutes?

3 Answers

That's a common issue: You can use Cloud Run which can run up to 60 minutes' timeout job, but the serverless product which can trigger it are more restrictive (30 minutes for Cloud Scheduler, 10 minutes for PubSub).

If you don't want to perform retries with Cloud Scheduler, you can simply call your Cloud Run service, and that's all. The Cloud Scheduler will consider the scheduling as failed (timeout) but the process on Cloud Run will continue (event if the Cloud Scheduler client stop listening the answer).

If you want to handle the errors and the retries, or if you want to have "successful" status in your Cloud Scheduler UI, the solution is to use Cloud Workflow. The workflow is really simple: call your API with the params (if applicable). Then here the process:

Finally, you have it, not optimized, but it works.

  1. Cloud Run has a default timeout of 5 minutes

  2. You can increase it by specifying the --timeout flag in gcloud run deploy

  3. If your timeout is going to be more than 15 minutes, you have to use gcloud beta run deploy

If you try to use gcloud run deploy for a timeout longer than 15m, you will get the following error - Timeout duration must be less than 15m. Timeouts above 15m are in Beta. Use "gcloud beta run ..."

Wrt:

Which is correct?

At the moment it says here : https://cloud.google.com/run/docs/configuring/request-timeout that :

 The timeout is set by default to 5 minutes and can be extended up to 60 minutes.

Wrt:

Can cloud run in fact run processes up to 60 minutes? and am I likely to have any issues using Cloud Schedular to trigger Cloud run if the process takes longer than 30 minutes?

At the moment it says here : https://cloud.google.com/run/docs/configuring/request-timeout that :

 Important: For a timeout longer than 15 minutes, Google recommends implementing retries and making sure the service is tolerant to clients re-connecting in case the connection is lost (either by ensuring requests are idempotent, or by designing request handlers in such a way that they can resume from the point where they left off). The longer the timeout is, the more likely the connection can be lost due to failures on the client side or the Cloud Run side. When a client re-connects, a new request is initiated and the client isn't guaranteed to connect to the same container instance of the service.
Related