在GAE / J中避免DeadlineExceededException的技巧? [英] Techniques to avoid DeadlineExceededException in GAE/J?

查看:142
本文介绍了在GAE / J中避免DeadlineExceededException的技巧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google App Engine / Java中开发Twitter4J Web应用程序。

我需要显示两个列表。一个是Twitter的朋友,另一个是追随者。用照片和屏幕名称。

对于有20-30个追随者和朋友的人来说,它工作得很好。但是当我尝试使用拥有此权限的用户时,它给了我 DeadlineExceededException 150多个追随者和朋友。



如果Web请求花费超过30秒的时间,GAE会抛出此异常。



那么我可以采用哪些技术来避免这种异常。



我应该为每个列表生成两个AJAX调用吗?页面加载后。所以每次通话都会有自己的30秒限制?

或者你还有什么想法?我已经离开了。



请帮忙。

解决方案

不当然,如果你打算一次询问所有的追随者/朋友(无论如何,这对于拥有大量追随者/朋友的人来说,Twitter api速率限制是个问题)。所以我假设你查询Twitter api中的有限数量的关注者/朋友,并使用Twitter分页来获取更多显示内容。



我的解决方案是,而且它也是我为推特实施的一项工作,就是从浏览器中完成状态/朋友和状态/关注者。这可以通过JavaScript添加一个html< script>在浏览器中标记状态网址和回调函数。这绕过GAE作为代理。这不仅可以避免GAE上的超时问题,而且还可以减少GAE中的调用次数/ CPU时间,这意味着如果您的应用程序按比例增加,将会更便宜,高于免费GAE限制。


I am developing an Twitter4J web application in Google App Engine/Java.

I need to show two lists. One is Twitter friends and other is followers. With photo and screen name.

It is working fine for people who have 20-30 followers and friends. But it gave me DeadlineExceededException when I try a user who has 150+ followers and friends.

GAE throws this exception if web request take time more than 30 seconds.

So what techniques I can adopt to avoid this exception.

Should I generate two AJAX calls for each of my list. After page loads. So that every call will have its own 30 secs limit?

Or what else you think? I am gone make it.

Please help.

解决方案

Not sure if you intend to query all followers/friends at once (it would be a problem with the Twitter api rate limit for people with a very large number of followers/friends anyway). So I assume you query the Twitter api for a limited number of followers/friends, and using the Twitter paging to get more as needed to show.

My solution would be, and it also something I've implemented for Twitter, is to do the statuses/friends and statuses/followers from the browser. This is possible via JavaScript by adding a html <script> tag with the status url and the callback function in the browser. This bypasses GAE as proxy. This not only avoids the timeout problem on GAE it also reduces the number of calls/cpu-time in GAE, which means it will be cheaper if your applications scales up, above the free GAE limit.

这篇关于在GAE / J中避免DeadlineExceededException的技巧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆