使用”Golang”在GAE中的成本/性能优势是什么?

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

what are the cost/perfomance advantages of using "golang" in GAE

问题

就每个实例的配额/使用限制而言,在Google appengine(GAE)中使用golang相比于其他在GAE中提供的语言(如python、java、php)是否有明显的改进/优势?或者基本上,不管使用哪种语言,实例的行为方式都是相同的,并且可以处理几乎相同数量的每秒最大请求/实例,考虑到这更多地涉及到“GAE负载均衡器”或基础设施,而不是所使用的编程语言,相同的逻辑也可以应用于内存和CPU使用情况吗?

英文:

In terms of the Quotas/Usage limits per instance, is there any considerable improvement/advantage when using golang in Google appengine GAE instead of other offered language that run within GAE like python, java,php or all of them behave the same?

Or basically any instance no matter the language in use, behave the same way and can handle barely the same amount of maximum requests/sec per instance considering that this concerns more to the "GAE load balancer" or infrastructure, rather than the used programming language, same logic could applied to the memory,cpu usage?

答案1

得分: 4

App Engine没有针对特定语言使用时的明确限制或限制。然而,不同的语言及其技术可能会暗示某些限制。例如,Java虚拟机实例本身需要更多的内存,并且启动时间更长(即使启用了预热请求),相比之下,使用Go的内置Web服务器启动的时间更短,因此在使用Java实例时,用于Web应用程序本身分配和使用的内存将更少(针对特定的计划/类型和实例)。

我没有具体的度量标准进行比较,但是(以Go为例):

“代码以源代码形式部署并在云中编译... Go是在App Engine上运行的第一种真正的编译语言。在App Engine上使用Go可以部署高效的CPU密集型Web应用程序。”(来源

如果你仔细思考一下,App Engine上的其他语言都是解释性的(包括Java,它是由虚拟机解释的字节码),而Go则被编译为并作为平台相关的本机代码运行。这已经说明了一些关于性能的问题。

关于一个“案例研究”,请查看以下博客文章:

从零开始:在24小时内在Google主页上发布

这篇博客还包含了一个由数百万人使用的真实应用程序的性能报告:

使用”Golang”在GAE中的成本/性能优势是什么?

这张图表 - 直接从App Engine仪表板中获取 - 显示了启动期间的平均请求延迟。如你所见,即使在负载下,延迟也不会超过60毫秒,中位延迟为32毫秒。考虑到我们的请求处理程序正在实时进行图像处理和编码,这是非常快速的。

App Engine使用Go标准库中包含的Web服务器来提供你的应用程序,这也意味着你可以轻松地将Go Web应用程序移植到App Engine,并且你可以准确地知道在App Engine上提供你的应用程序的Web服务器会有什么样的表现。

找到了Python、Java和Go的官方时间比较

App Engine系统状态可以被认为是官方的,并且是一个很好的比较基准。

你可以点击属于特定日期和语言的任何单元格,获取详细的历史统计数据,包括静态和动态GET延迟(安全和非安全)、错误率和CPU使用率/延迟。这些统计数据是在已经启动并准备好提供服务的实例上进行测量的。

对于2015年1月27日的分析,以下是关于GoJavaPython的结论:

  • 动态延迟对于所有语言来说大致相同

  • CPU延迟(计算第33个斐波那契数)最好的是Java,其次是Go,最慢的是Python。

  • 静态文件服务时间大致相同,但Go最快。

英文:

App Engine doesn't have explicit limits or restrictions that would apply only when using a specific language. However the languages and their technologies might imply certain limitations, for example a Java Virtual Machine instance by itself requires significantly more memory and has significantly higher startup time (even when warmup requests are enabled) than starting the built-in web server of Go, so in case of a Java instance less memory will remain for the webapp itself to allocate and use (for a specific plan/type and instance).

I don't have concrete measures to compare, but (in case of Go):

> "Code is deployed in source form and compiled in the cloud... Go is the first true compiled language that runs on App Engine. Go on App Engine makes it possible to deploy efficient, CPU-intensive web applications". (source)

If you think about it, other languages at App Engine are all interpreted (including Java which is byte code interpreted by a Virtual Machine) while Go is compiled into and runs as platform dependent native code. This should already tell something about performance.

For a "case-study" check out the following blog post:

From zero to Go: launching on the Google homepage in 24 hours

This blog also contains some performance report of a real-world app used by millions:

> 使用”Golang”在GAE中的成本/性能优势是什么?
>
> This chart - taken directly from the App Engine dashboard - shows average request latency during launch. As you can see, even under load it never exceeds 60 ms, with a median latency of 32 milliseconds. This is wicked fast, considering that our request handler is doing image manipulation and encoding on the fly.

App Engine uses the web server that is included in the Go standard library to serve your app, so that also means you can easily port a Go web app to App Engine, and that you know exactly what to expect from the web server serving your app on App Engine.

Found Official time comparisions of Python, Java and Go

The App Engine System Status can be considered official and a good comparision base.

You can click on any cells belonging to a specific day and language, and you get detailed historical statistics for Static and Dynamic GET latency (both secure and unsecure), Error rates, CPU usage/latency. These statistics are measured on an instance that is already up and ready to serve.

Analysing it for the day of January 27, 2015 here are the conclusions for Go, Java and Python:

  • Dynamic latency is roughly the same for all

  • CPU latency (to compute the 33<sup>rd</sup> Fibonacci number) is best for Java, then Go and slowest is Python.

  • Static file serving time is roughly the same but Go is fastest.

huangapple
  • 本文由 发表于 2015年1月29日 20:43:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/28215085.html
匿名

发表评论

匿名网友

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

确定