I have a task that exceeds more than 10 minutes deadline of the Task Queue. Going through different documentations, I found that using modules I could run an instance that would
Disclaimer: the answer is based exclusively on docs (I'm actually using python - same concepts but different configs).
To make a service/module allow long-running task you have to configure it for basic or manual scaling. From Scaling types and instance classes (the Deadline
row in the table):
Manual scaling
column:Requests can run indefinitely. A manually-scaled instance can choose to handle /_ah/start and execute a program or script for many hours without returning an HTTP response code. Tasks can run up to 24 hours.
Basic scaling
column:Same as manual scaling.
The module scaling configs, done via the respective module's appengine-web.xml
file, are described in Scaling elements:
<manual-scaling>
:Optional. The element enables manual scaling for a module and sets the number of instances for a module.
<basic-scaling>
:Optional. The element sets the number of instances for a module.
As for the actual conversion to modules, complement the guide you pointed to with the Configuration Files (includes an example) and the appengine-web.xml Syntax (see module
and service
configs).
About appengine-application.xml
, from Configuration Files:
The META-INF directory has two configuration files:
appengine-application.xml
andapplication.xml
. Theappengine-application.xml
file contains general information used by App Engine tools when your app is deployed...
...
Note that while every
appengine-web.xml
file must contain the<application>
tag, the name you supply there is ignored. The name of the application is taken from the<application>
tag in theappengine-application.xml
file.
To direct a certain queue to a certain service/module you use the queue.xml
file. From Syntax:
<target>
(push queues):Optional. A string naming a module/version, a frontend version, or a backend, on which to execute all of the tasks enqueued onto this queue.
The string is prepended to the domain name of your app when constructing the HTTP request for a task. For example, if your app ID is my-app and you set the target to my-version.my-service, the URL hostname will be set to my-version.my-service.my-app.appspot.com.
If target is unspecified, then tasks are invoked on the same version of the application where they were enqueued. So, if you enqueued a task from the default application version without specifying a target on the queue, the task is invoked in the default application version. Note that if the default application version changes between the time that the task is enqueued and the time that it executes, then the task will run in the new default version.
If you are using modules along with a dispatch file, your task's HTTP request might be intercepted and re-routed to another module.
Modules and Services are the same thing, they're similar to the old backends (which still work, but are deprecated).
There are two basic ways of getting modules to work:
The second option is probably easier, because it's just a matter of changing your application-web.xml. You could have a repo or branch per module, or just a build process that changes the module you're targeting.
Right now your application-web.xml probably has something like this:
<application>@appId@</application>
<version>@appVersion@</version>
<module>default</module>
change it to something like this
<application>@appId@</application>
<version>@appVersion@</version>
<module>long-running-service</module>
<instance-class>B1</instance-class>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
You configure the queue itself to target a specific module in queue.xml
See here.