将 python 与更快的语言混合以在 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅 我可以用 Java 编写部分 Google App Engine 代码,用 Python 编写其他部分吗?了解如何使用多种语言。
基本上,给定应用程序的每个版本只能使用一种运行时语言。
但是,您可以拥有两个不同版本的应用程序,以不同的语言编写,并且它们可以通过数据存储来回传递信息。
此外,您可以拥有两个不同的应用程序,使用两种不同的语言,然后您可以通过请求来回传递信息。
See 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.
我认为你在这里陷入了过早的优化。对于几乎所有 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.