I have a Java server running on GAE to support an Android app.
When the app is launched it makes a request to the server - that request should return as quickly as possible. That request should also trigger a few seconds of secondary processing - secondary in that it is not necessary for the response, so I would like it do occur after the request is complete.
Here are the options I'm considering for how to do that:
The most obvious solution is for the app to perform a second request when the first one completes. This seems rather wasteful as there will usually be no data to send or receive. In cases where the secondary processing does yield some additional data for the client (20%) I could just as well send it via GCM now that GCM supports payloads.
DeferredTasks sound perfect, but since they are implemented on top of task queues, I guess they suffer from the same issues as task queues.
TaskQueues sound suitable too, but a little reading suggests that their timing is highly variable - there is often a considerable delay. As I mention above, in 20% of cases my secondary processing will yield some additional data to send to the client, to be displayed to the user.
If my task were executed within 10 seconds, 80% of the time, that would be fine, but it sounds like that is not the case. [edit: sorry, didn't mean to suggest that the remaining 20% don't matter - I still want them to occur within 20-30s, e.g. while user is still in the app.]
Is there some way I can configure my app such that a push task queue gets reasonably high priority without incurring undue costs?
Async Url Fetch. It seems to me that if I do an async url fetch to one of my own URL's, just before completing the initial request, then this would serve my purpose. The main negative I can think of that this may cause GAE to launch a new instance of my app since it is trying to handle the new request before the initial request is complete. I'd rather have my secondary processing happen in serial with my initial request for the sake of efficiency and cost.
Threads are not an option AFAIK. Threads spawned in my request handler can not live beyond the life of the request handler itself.
So, which of these options (or others?) would best suite my purposes?
Read full article from How to do some processing after response on GAE - Java, Google-app-engine - Answer - Techwikihow
No comments:
Post a Comment