Skip to content Skip to sidebar Skip to footer

Increase Time To Run Code For Google Flexible App Engine Delaying Deadlineexceedederror

I have a single function running on Google App Engine Flexible as part of an API call. The structure is something like this import externalmod ... ... @app.route('/calc_here') def

Solution 1:

Since i didnt get any answer I kept up the search. I realise many others also have similar issues.

The first thing to note is that GAE flexible environment does not have most of the standard constraints like in standard environment. This means that DeadlineExceededError does not exist since there is no deadline of 60 sec. All the modules and codes run just like they would on any computer since it is all contained inside Docker containers.

https://cloud.google.com/appengine/docs/flexible/python/migrating

Additionally, there is no google.appengine module. Depending on the language being used, all cloud interactions should happen through google.cloud API https://cloud.google.com/apis/docs/overview

Then what could possibly explain this timeout? I checked the logging -logs in the google cloud project console. I saw that the relevant error is actually [CRITICAL] WORKER TIMEOUT which occurred exactly 30 seconds after the function was called. This has got nothing to do with GAE flex but with the server framework. In my case `gunicorn'.

The answer is provided here actually https://serverfault.com/questions/490101/how-to-resolve-the-gunicorn-critical-worker-timeout-error/627746

Basically, using the documentation http://docs.gunicorn.org/en/latest/settings.html#config-file

the only change needed would be in the app.yaml file

where earlier it was

runtime: pythonenv: flexentrypoint: gunicorn -b :$PORT main:app

gunicorn workers have a default 30 sec timeout

change this to

entrypoint: gunicorn -t 120 -b :$PORT main:app

here the timeout is 120 seconds, but depending on some trial and error it can be optimised. This however, solved my particular problem of running a code that takes longer than usual

Post a Comment for "Increase Time To Run Code For Google Flexible App Engine Delaying Deadlineexceedederror"