谷歌应用引擎在实例休眠后是否缓存编译的Go代码?

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

Does Google App Engine cache compiled go code after instance sleeps?

问题

Google App Engine在标准环境中会将实例置于休眠状态,并在有新请求时重新启动它们。我想知道当实例唤醒时,我的Go代码是否会重新编译,或者编译后的代码是否被缓存。

如果编译后的代码被缓存,那么使用编译器计算数组大小不应该对实例的启动时间产生任何影响,对吗?

例如,当实例从休眠状态唤醒后,下面的代码:

myCompilerCountedArray := [...]string{"1","2","3"}

myUserCountedArray := [3]string{"1","2","3"}

在性能上是否相同?

英文:

Google App Engine will put instances to sleep in the Standard Environment, and boot them back up once a new request comes in. I am wondering if my Go code will be compiled again once the instance wakes up or if the compiled code is cached.

If the compiled code is cached, then using the compiler to count the size of an array shouldn't have any impact on the boot time for an instance right?

For instance, would

myCompilerCountedArray := [...]string{"1","2","3"}

and

myUserCountedArray := [3]string{"1","2","3"}

have the same performance when an instance is started after going to sleep?

答案1

得分: 1

代码只在部署应用程序时编译一次。

引用自App Engine标准环境文档:

每当您上传新代码时,服务器端会自动重新构建您的应用程序,如果您正在运行本地开发服务器,SDK会在您更改代码时自动即时重新编译源代码。

此外,Go运行时环境文档中提到:

与Python SDK一样,只要您更改了源代码,您的应用程序就会自动重新构建。

当启动一个实例时,App Engine只加载和运行可执行二进制文件。尽管文档中没有明确提到这一点,但以下已知问题表明了这一点:

请求失败,因为应用程序二进制文件丢失

英文:

The code is compiled only once, when you deploy the app.

Quote from the The App Engine Standard Environment doc:
> Your app is automatically re-built on the server side whenever you upload new code, and if you are running the local development server the SDK automatically recompiles sources on-the-fly when you change them.

Also, the Go Runtime Environment doc states:
> And—as with the Python SDK—your app will be automatically re-built whenever you change the source.

When an instance is started, app engine only loads and runs the executable binary. This fact doesn't seem to be mentioned in the documentation, but it's indicated by the following known issue:
>Request failed because the app binary was missing

huangapple
  • 本文由 发表于 2017年7月10日 07:34:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/45002024.html
匿名

发表评论

匿名网友

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

确定