Reputation: 544
I have a PHP script that is running on Google Cloud Engine which fires an SQL query and the query sometimes takes more than 60 second to execute.
If the request fails to return within 60 seconds and a DeadlineExceededError
is thrown and not caught, the request is aborted and a 500 internal server error is returned. Following is mentioned in the documentation.
The Google App Engine request timer (Java/Python/Go) ensures that requests have a finite lifespan and do not get caught in an infinite loop. Currently, the deadline for requests to frontend instances is 60 seconds. (Backend instances have no corresponding limit.) Every request, including warmup (request to /_ah/warmup) and loading requests ("loading_request=1" log header), is subject to this restriction
I have gone through this link which explains how to avoid such error but my query is running on a heavy database, which takes a while to fetch all results.
My question is how can I increase the request timer to be able to run long running tasks. If not possible is there any alternatives to achieve such a thing.
Upvotes: 1
Views: 1371
Reputation: 35
If your code is running inside a request handler, then by default there is an App-Engine-enforced 60 second deadline. You can't change it. See the "Deadlines" row / "automatic scaling" column of the chart on this page under "Scaling types":
https://developers.google.com/appengine/docs/java/modules/
However, this code will be able to run for some hours if you change your module to use "manual scaling" and a "B1"-"B4" instance. Example:
default/src/main/webapp/WEB-INF/appengine-web.xml:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myapp</application>
<module>default</module>
<version>1</version>
<threadsafe>true</threadsafe>
<instance-class>B1</instance-class>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
On this type of instance, your requests will typically not time out for hours.
Upvotes: 1