开发者

Better ways to handle AppEngine requests that time out?

开发者 https://www.devze.com 2023-01-23 14:25 出处:网络
Sometimes, with requests that do a lot, Google AppEngine returns an error.I have been handling this by some trickery: memcaching intermediate processed data and just requesting the page again.This oft

Sometimes, with requests that do a lot, Google AppEngine returns an error. I have been handling this by some trickery: memcaching intermediate processed data and just requesting the page again. This often works because the memcached data does not have to be recalculated and the request finishes in time.

However... this hack requires seeing an error, going back, and clicking again. Obviously less than ideal.

Any suggestions?

inb4: "optimize your process better", "split your page into sub-processes", and "use taskqueue".

Thanks for any thoughts.

Edit - To clarify: Long wait for requests is ok because the function is administrative. I'm basically looking to run a data-mining function. I'm searching over my datastore and modifying a bunch of objects. I think the correct answer is that AppEngine may not be the right tool for this. I should be exporting the data to a computer where I can run functions like this on my own. It seems AppEngine is really intended for serving 开发者_StackOverflow中文版with lighter processing demands. Maybe the quota/pricing model should offer the option to increase processing timeouts and charge extra.


If interactive user requests are hitting the 30 second deadline, you have bigger problems: your user has almost certainly given up and left anyway.

What you can do depends on what your code is doing. There's a lot to be optimized by batching datastore operations, or reducing them by changing how you model your data; you can offload work to the Task Queue; for URLFetches, you can execute them in parallel. Tell us more about what you're doing and we may be able to provide more concrete suggestions.


I have been handling something similar by building a custom automatic retry dispatcher on the client. Whenever an ajax call to the server fails, the client will retry it.

This works very well if your page is ajaxy. If your app spits entire HTML pages then you can use a two pass process: first send an empty page containing only an ajax request. Then, when AppEngine receives that ajax request, it outputs the same HTML you had before. If the ajax call succeeds it fills the DOM with the result. If it fails, it retries once.

0

精彩评论

暂无评论...
验证码 换一张
取 消