GCP Cloud Scheduler job for App Engine HTTP target is timing out after 10 minutes

此生再无相见时 提交于 2021-01-29 05:48:11

问题


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:


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.



来源:https://stackoverflow.com/questions/62751234/gcp-cloud-scheduler-job-for-app-engine-http-target-is-timing-out-after-10-minute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!