GAE Go – “此请求导致为您的应用程序启动了一个新进程…”

huangapple go评论87阅读模式
英文:

GAE Go - "This request caused a new process to be started for your application..."

问题

我现在第二次遇到这个问题,我想知道是否有任何解决办法。我在Google App Engine上运行一个依赖于通过HTTP JSON RPC与网站频繁通信的应用程序。看起来GAE有随机显示日志中的这样一条消息的倾向:

> "这个请求导致为您的应用程序启动了一个新的进程,
> 因此导致您的应用程序代码首次加载。
> 这个请求可能比您的应用程序的典型请求花费更长的时间和使用更多的CPU。"

并且没有警告地重置了RAM中存储的所有变量。无论我多少次设置变量或上传更新的代码到GAE,相同的过程一遍又一遍地发生,尽管增加应用程序版本号似乎可以解决这个问题。

我如何获取有关此行为的更多信息,如何避免它并防止我的Golang应用程序在Google App Engine上丢失数据?

编辑:

RAM中存储的变量是一些小的字符串、字节、布尔值和指针类。没有太复杂或太大的东西。

Google App Engine似乎在较重的使用情况下在几秒钟内“启动一个新的进程”,这对于应用程序因长时间未使用而被关闭来说不应该是足够长的时间。应用程序被上传到GAE、设置其变量和创建新进程之间的时间间隔少于一分钟。

英文:

I've encountered this problem for a second time now, and I'm wondering if there is any solution to this. I'm running an application on Google App Engine that relies on frequent communication with a website through HTTP JSON RPC. It appears that GAE has a tendency to randomly display a message like this in the logs:

> "This request caused a new process to be started for your application,
> and thus caused your application code to be loaded for the first time.
> This request may thus take longer and use more CPU than a typical
> request for your application."

And reset all variables stored in RAM without warning. The same process happens over and over no matter how many times I set the variables again or upload newer code to GAE, although incrementing the app version number seems to solve the problem.

How can I get more information on this behaviour, how to avoid it and prevent data loss of my Golang applications on Google App Engine?

EDIT:

The variables stored in RAM are small classes of strings, bytes, bools and pointers. Nothing too complicated or big.

Google App Engine seems to "start a new process" in matter of seconds of heavier use, which shouldn't be long enough time for the application to be shut down for not being used. The timespan between application being uploaded to GAE, having its variable set and a new process being created is less than a minute.

答案1

得分: 16

你是否意识到GAE是一种云托管解决方案,可以根据负载自动管理实例?这是它的主要特点,也是人们使用它的原因。

当负载增加时,GAE会创建一个新的实例,当然,这个实例的所有RAM变量都是空的。

解决方案不是期望变量可用或将它们存储到永久存储(会话、内存缓存、数据存储)并在请求开始时加载它们,如果不存在的话。

英文:

Do you realize that GAE is a cloud hosting solution that automatically manages instances based on the load? This is it's main feature and reason people are using it.

When load increases, GAE creates a new instance, which , of course, has all RAM variables empty.

The solution is not to expect variables to be available or store them to permanent storage at the end of request (session, memcache, datastore) and load them if not present at the beginnig of request.

答案2

得分: 5

您可以在这里阅读有关GAE实例的文档,并查看性能部分:

http://code.google.com/appengine/kb/java.html

在您的情况下,如果有小型可用数据,如果是静态数据,则可以在新实例启动时将其加载到内存中。如果是动态数据,则应使用其API将其保存到数据库中。

我建议保持GAE实例活动的方法是,要么支付Always-On服务的费用,要么按照我在这里使用cron的建议进行操作:

http://rwyland.blogspot.com/2012/02/keeping-google-app-engine-gae-instances.html

我使用了我称之为“主要计划”的3、7、11分钟cron作业。

英文:

You can read about GAE instances in their documentation here, check out the performance section:

http://code.google.com/appengine/kb/java.html

In your case of having small data available, if its static then you can load it into memory on startup of a new instance. If it's dynamic data, you should be saving it to the database using their api.

My recommendation for keeping a GAE instance alive, either pay for the Always-On service or follow my recommendations for using a cron here:

http://rwyland.blogspot.com/2012/02/keeping-google-app-engine-gae-instances.html

I use what I call a "prime schedule" of a 3, 7, 11 minute cron job.

答案3

得分: 2

如果您想要具有常驻内存的长时间运行实例,您应该考虑使用后端

英文:

You should consider using Backends if you want long running instances with resident memory.

huangapple
  • 本文由 发表于 2012年3月6日 11:18:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/9577457.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定