1
votes

I have an App Engine app and I had some App Engine cron jobs in it which was taking longer than 10minutes and hence failing(due to the limitation of App Engine cron job max time being 10min).

I decided to move it to Cloud Scheduler and created a job with App Engine HTTP target with below parameters. (attempt-deadline is the parameter where I tried to increase the time)

gcloud beta scheduler jobs create app-engine daily-import --schedule="0 */3 * * 1" --attempt-deadline=21600s --version="test-v1" --http-method="GET" --description="Daily Import" --relative-url="/api/test"

But I am surprised to say that the job still fails after 10min with an error message popping up in logger as

"Process terminated because the request deadline was exceeded. Please ensure that your HTTP server is listening for requests on 0.0.0.0 and on the port defined by the PORT environment variable. (Error code 123)"

Please note that the end point is working(the required code is being executed but failing in between due to deadline).

As per the scheduler doc The allowed duration for App Engine HTTP targets is in between 15 seconds and 24 hours.

Has anyone ever faced a similar issue? What could be the possible solution?

1

1 Answers

3
votes

Learned it the hard way. It has nothing to do with the cloud scheduler setup but the scaling type of my App Engine.

There are three scaling types of App Engine.

  1. Automatic scaling
  2. Basic Scaling
  3. Manual Scaling
  • In automatic scaling request is timed out after 10 minutes for HTTP requests and task queue tasks.
  • In basic scaling and manual scaling, the timeout duration is 24 hours, but you need to also consider the idle_timeout (instance shut down wait time)

So, if you have basic or manual scaling, you would get the opportunity to run a job for 24 hours. And in order to avoid any timeout error in cloud scheduler you need to provide the --attempt-deadline parameter of cloud scheduler (which should be in sync with the max time your job takes to complete).

Hope it helps.