在GAE中将Python与更快的语言混合以进行优化

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

Mixing python with a faster language for optimization in GAE

问题

我是Python和GAE世界的新手,我有一个问题。
使用Python的正常方法是只在需要时优化代码,修复最紧迫的瓶颈。
而实现这一点的一种方式是通过用C重写程序的最关键部分。

使用GAE,我们会永远失去这个可能性吗?
由于Google的Go语言现在(或者一旦它被编译得更高效)是GAE中最快的语言,是否会有一种方法将Python和Go混合在同一个应用程序中?
还有其他什么方法可以实现类似的结果?

英文:

I'm a newbie in the Python and GAE world and I have a question.
With Python the normal approach is to only optimize the code when needed, fixing the more urgent bottlenecks.
And one of the ways to achieve that is by rewriting the most critical parts of the program in C.

By using GAE are we losing this possibility forever?
Since Google's Go language is now (or it will be as soon as it is compiled more efficiently) the fastest language in GAE, will there be a way to mix Python and Go in the same app?
What other ways could be used to achieve a similar result?

答案1

得分: 9

请参考https://stackoverflow.com/questions/2342059/can-i-write-parts-of-the-google-app-engine-code-in-java-other-parts-in-python,了解如何使用多种语言。

基本上,每个应用的每个版本只能使用一种运行时语言。

但是,您可以有两个不同版本的应用,使用不同的语言编写,并且它们可以通过数据存储传递信息。

此外,您可以有两个不同语言的应用,并且可以通过请求来回传递信息。

英文:

See https://stackoverflow.com/questions/2342059/can-i-write-parts-of-the-google-app-engine-code-in-java-other-parts-in-python for how to use multiple languages.

Basically, each version of a given app can only use one runtime language.

But, you can have two different versions of your app, written in different languages, and they can pass information back and forth through the datastore.

Also, you can have two different apps, in two different languages, and you can have then pass information back and forth through requests.

答案2

得分: 5

我认为你在这里过早地进行了优化。对于几乎所有的Web应用程序来说,大部分时间都花在了RPC上,等待系统的其他部分执行一些操作,比如处理数据存储查询。剩下的时间中,很大一部分通常也是在C代码中花费的。只有相对较少的Web应用程序需要在为典型查询提供服务时进行大量的处理器密集型工作。

如果你的应用程序是其中之一,考虑到App Engine上不支持C扩展,你可能需要重新考虑是否将整个应用程序都用Python编写,而选择Java或Go。如果你的应用程序是那99%的应用程序之一,它们在处理典型请求时不需要进行太多处理器密集型工作,那就不用担心这个问题。

英文:

I think you're falling for premature optimisation here. For nearly all webapps, the majority of time spent is in RPCs, waiting for the rest of the system to do something such as process datastore queries. Of the remainder, a significant fraction is often spent in C code anyway. There are relatively few webapps that need to do a lot of processor-intensive work in order to serve a typical query.

If your app is one of those, you may want to reconsider writing your entire app in Python, given the unavailability of C extensions on App Engine, and choose Java or Go. If your app is one of the 99% that don't need to do much processor intensive work for typical requests, don't worry about it.

huangapple
  • 本文由 发表于 2011年7月24日 21:43:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/6807119.html
匿名

发表评论

匿名网友

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

确定