Google App Engine 上无限循环的后果?
我不是 Google App Engine 用户。不过,据我了解,您需要按 CPU 时间和其他资源付费。如果你碰巧创建了无限循环,会产生什么后果?谷歌会终止它,还是你必须自己手动完成?
我是一名业余开发者,担心一个小错误可能最终导致数百美元的损失。
I am not a Google App Engine user. However, I understand you're billed for CPU time and other resources. What are the consequences if you happen to create an infinite loop? Will Google ever terminate it, or will you have to do it yourself manually somehow?
I'm a hobbyist developer worried about a small error that might end up costing hundreds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(我是 Google 员工,但对 AppEngine 的经验很少。请不要将此视为“官方”回复。)
我猜您正在使用 Java servlet API - 如果没有,请说明。
来自 AppEngine Servlet 文档:
我不知道这种情况如何/是否发生在紧密循环中,这不允许虚拟机在“正常”Java 中中断它。
(I'm a Google employee but have little experience with AppEngine. Please don't consider this an "official" response.)
I'm guessing you're using the Java servlet API - if not, please specify.
From the AppEngine servlet docs:
I don't know how/whether this occurs in a tight-loop which wouldn't allow the VM to interrupt it in "normal" Java.
虽然 Jon 处理了无限循环的低级别情况,但也可能存在一种情况,即您的一个处理程序被重复调用过多次 - 也许您不小心配置了某些东西来每秒备份整个数据存储,而不是每天一次。理论上,您可能会消耗大量资源,即使是 30 秒的块。但是,您仍然不会面临收取巨额费用的危险。您可以选择设置每天“花费”的限额。如果您没有剩余配额,您的应用程序将返回错误,而不是将您送入债务人监狱。
While Jon handled the low level case of an infinite loop, there could also be a situation where one of your handlers is called repeatedly an excessive amount of times - perhaps you accidentally configure something to back up your entire datastore every second instead of once a day. Theoretically, you could use up a lot of resources, even in 30 second chunks. However, you would still not be in danger of racking up a huge amount of charges. You have the option of setting a limit on how much you want to "spend" per day. If you have no quota left, your app will return an error, not put you into debtor's prison.
Google AppEngine 对请求终止前可能需要的时间设置了限制,
有一个 大约 30 秒的限制,规定请求在终止之前必须花费多长时间。但是,在进程终止前不久,将引发
DeadlineExceededError
异常。此外,还有每分钟配额,可防止应用程序短时间内消耗过多配额。在正常情况下,您的应用程序不太可能超出每分钟配额,但如果需要,可以增加此配额可以请求。
Google AppEngine imposes a limit on how long a request may take before it is terminated,
There is a roughly 30 second limit imposed on how long a request must take before it is terminated. However, shortly before the process is terminated, a
DeadlineExceededError
exception will be thrown.Additionally there are per-minute quotas to prevent the application from consuming too much quota in a short period of time. It is very unlikely that your application will exceed the per-minute quota under normal conditions, but, if needed an increase to this quota can be requested.