如何让 App Engine/Java 应用程序在来自 Java/Python Web cron 的聋请求的情况下保持运行?
- App Engine 允许您在 30 秒内加载应用程序
- 我的应用程序大约需要 30 秒 - 有时更长,有时更少。 我不知道如何解决这个问题。
- 如果应用程序空闲(一段时间内没有收到请求),则需要重新加载。
因此,为了避免需要重新加载应用程序,我想通过经常 ping 应用程序来模拟用户活动。
但有一个问题。 。 。
如果我 ping 应用程序并且它已被 App Engine 卸载,则我的 Web 请求将是对该应用程序的第一个请求,并且该应用程序将尝试重新加载。 这可能需要超过 30 秒并超出加载时间限制。
所以我的想法是 ping 应用程序但不等待响应。 我通过从浏览器访问该站点,发出请求并立即关闭浏览器来手动模拟这一点 - 这似乎使应用程序保持活动状态。
对于在 Python 或 Java Web cron 中执行此操作的好方法有什么建议(我假设 Python 解决方案会更简单)?
- App Engine allows you 30 seconds to load your application
- My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.
- If the app is idle (does not receive a request for a while), it needs to be re-loaded.
So, to avoid the app needing to be reloaded, I want to simulate user activity by pinging the app every so often.
But there's a catch . . .
If I ping the app and it has already been unloaded by App Engine, my web request will be the first request to the app and the app will try to reload. This could take longer than 30 seconds and exceed the loading time limit.
So my idea is to ping the app but not wait for the response. I have simulated this manually by going to the site from a browser, making the request and immediately closing the browser - it seems to keep the app alive.
Any suggestions for a good way to do this in a Python or Java web cron (I'm assuming a Python solution will be simpler)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 App Engine 内置的 cron 让您的应用程序保持活力。
It would probably be easier use the cron built in to App Engine to keep your application alive.
我想你想要的只是:
I think what you want is just:
最简单的 Java http pinger:
the simplest Java http pinger:
App Engine 还有一个新的 PAY 功能,您可以让它“永远在线”。 每天费用约为 0.30 美元美分。 如果您不介意支付该功能,只需进入您的计费设置并启用它即可。 我相信它可以保证至少有 3 个实例始终运行。
(我没有意识到点击 /ping url 导致实例旋转会导致它超过 30 秒限制!)
App engine also has a new PAY feature where you can have it "always-on". Costs about $0.30 USD cents a day. Just go into your billing settings and enable it if you don't mind paying for the feature. I believe it guarantees you at least 3 instances always running.
(I didn't realize hitting a /ping url which caused an instance to spin up would cause it to exceed the 30 sec limit!)