I'd like to start a long running task on the Backend instance. This backend task will be started by the front code (servlet) via a HTTP request. This is all described in docs and it works for me.
What troubles me is that front end instances have a request duration limit of 30s (or is it 60s now?). During that request, the front end will call the backend to start the long running task. However since this task is long running and front end is waiting for it to finish and will timeout.
The question is how to make a HTTP request from front end to start the long-running backend task, so that the front end will not get a timeout and backend will continue running?
What I already tried is:
- Start a separate thread in the backend. My IDE (Idea) complains about this, saying that Thread are not allowed on App Engine. Are they allowed in backend instances?
- In the backend servlet, flush the reply and close the writer() - nothing happens. Front end does not receive anything.
I tried all this on dev server. Should it be tried on production?
The way to do long-running requests on AppEngine, on frontend or backend, is to use task queues. Tasks have a 10-minute timeout rather than 60 seconds, but if you need even more time you can run it on a backend instance by giving it a target name.