英文:
Resource usage of google Go vs Python and Java on Appengine
问题
谷歌Go在Appengine上使用的资源比Python和Java少吗?Go的实例启动时间比Java和Python的启动时间快吗?
Go程序是以二进制文件还是源代码上传的?如果以源代码上传,是在每个实例启动时编译一次还是只编译一次?
换句话说,从成本的角度来看,使用Go在app engine上会有什么好处?(只考虑appengine资源的成本,不考虑开发时间)
英文:
Will google Go use less resources than Python and Java on Appengine? Are the instance startup times for go faster than Java's and Python's startup times?
Is the go program uploaded as binaries or source code and if it is uploaded as source code is it then compiled once or at each instance startup?
In other words: Will I benefit from using Go in app engine from a cost perspective? (only taking to account the cost of the appengine resources not development time)
答案1
得分: 48
是的,Go实例的内存比Python和Java低(小于10MB)。
是的,Go实例的启动速度比Java和Python快,因为运行时只需要读取一个可执行文件来启动应用程序。
此外,即使目前是单线程的,Go实例可以使用goroutine并发处理传入的请求,这意味着如果一个goroutine正在等待I/O,另一个goroutine可以处理传入的请求。
Go程序以源代码的形式上传并在部署新版本应用程序时使用SDK进行编译(一次)生成二进制文件。
换句话说,从成本的角度来看,使用Go在应用引擎中会有好处。
就性能/价格比而言,Go运行时绝对具有优势,但它不会影响其他API配额的定价,如Peter的回答所述。
英文:
> Will google Go use less resources than Python and Java on Appengine?
> Are the instance startup times for go faster than Java's and Python's
> startup times?
Yes, Go instances have a lower memory than Python and Java (< 10 MB).
Yes, Go instances start faster than Java and Python equivalent because the runtime only needs to read a single executable file for starting an application.
Also even if being atm single threaded, Go instances handle incoming request concurrently using goroutines, meaning that if 1 goroutine is waiting for I/O another one can process an incoming request.
> Is the go program uploaded as binaries or source code and if it is
> uploaded as source code is it then compiled once or at each instance
> startup?
Go program is uploaded as source code and compiled (once) to a binary when deploying a new version of your application using the SDK.
> In other words: Will I benefit from using Go in app engine from a cost
> perspective?
The Go runtime has definitely an edge when it comes to performance / price ratio, however it doesn't affect the pricing of other API quotas as described by Peter answer.
答案2
得分: 23
实例的成本只是您应用程序成本的一部分。我目前只使用Java运行时,所以我不知道使用Python或Go会更高效还是更低效,但我不认为差异会有数量级的不同。我知道实例不是您需要考虑的唯一成本。根据您的应用程序的功能,您可能会发现API或存储成本比运行时之间的微小差异更重要。无论您使用哪种运行时,所有API成本都将相同。
语言可能会影响这些成本:
- 按需前端实例
- 预留前端实例
- 后端实例
与语言无关的成本:
- 高复制数据存储(每存储一GB)
- 出站带宽(每GB)
- 数据存储API(每操作)
- Blob存储API(每GB)
- 邮件API(每封邮件)
- XMPP API(每个数据包)
- Channel API(每个通道)
英文:
The cost of instances is only part of the cost of your app. I only use the Java runtime right now, so I don't know how much more or less efficient things would be with Python or Go, but I don't imagine it will be orders of magnitude different. I do know that instances are not the only cost you need to consider. Depending on what your app does, you may find API or storage costs are more significant than any minor differences between runtimes. All of the API costs will be the same with whatever runtime you use.
Language "might" affect these costs:
- On-demand Frontend Instances
- Reserved Frontend Instances
- Backed Instances
Language Independent Costs:
- High Replication Datastore (per gig stored)
- Outgoing Bandwidth (per gig)
- Datastore API (per ops)
- Blobstore API storge (per gig)
- Email API (per email)
- XMPP API (per stanza)
- Channel API (per channel)
答案3
得分: 17
问题大部分是无关紧要的。
Go应用程序的最小内存占用量小于Python应用程序,而Python应用程序的最小内存占用量小于Java应用程序。它们的每个实例的成本都是相同的,所以除非您的应用程序在额外的堆空间下表现更好,否则这个问题是无关紧要的。
Go的启动时间小于Python的启动时间,而Python的启动时间小于Java的启动时间。除非您的应用程序有特定的原因需要频繁启动/关闭实例,从成本的角度来看,这是无关紧要的。另一方面,如果您有一个在非常短的时间段内异常爆发的应用程序,启动时间可能是一个优势。
正如其他答案中提到的,许多成本在所有平台上都是相同的,特别是数据存储操作。在Go与Python与Java之间选择对实例小时账单产生影响的程度与以下相关:
-
您的应用程序是否生成大量垃圾?对于许多应用程序来说,最大的计算成本是垃圾收集器。Java拥有迄今为止最成熟的垃圾收集器,而基本操作如序列化比Python快得多。从初步的网络搜索来看,Go的垃圾收集器似乎是一个持续发展的课题,但并不是一个引以为傲的问题(至少目前还不是)。
-
您的应用程序是否计算密集型?对于数学运算,Java(JIT编译)和Go可能比Python更好。
这三种语言都有各自的优点和缺点。在大多数情况下,最好让其他问题占主导地位 - 您最喜欢使用哪种语言?
英文:
The question is mostly irrelevant.
The minimum memory footprint for a Go app is less than a Python app which is less than a Java app. They all cost the same per-instance, so unless your application performs better with extra heap space, this issue is irrelevant.
Go startup time is less than Python startup time which is less than Java startup time. Unless your application has a particular reason to churn through lots of instance startup/shutdown cycles, this is irrelevant from a cost perspective. On the other hand, if you have an app that is exceptionally bursty in very short time periods, the startup time may be an advantage.
As mentioned by other answers, many costs are identical among all platforms - in particular, datastore operations. To the extent that Go vs Python vs Java will have an effect on the instance-hours bill, it is related to:
-
Does your app generate a lot of garbage? For many applications, the biggest computational cost is the garbage collector. Java has by far the most mature GC and basic operations like serialization are dramatically faster than with Python. Go's garbage collector seems to be an ongoing subject of development, but from cursory web searches, doesn't seem to be a matter of pride (yet).
-
Is your app computationally intensive? Java (JIT-compiled) and Go are probably better than Python for mathematical operations.
All three languages have their virtues and curses. For the most part, you're better off letting other issues dominate - which language do you enjoy working with most?
答案4
得分: 1
这可能更多关于如何分配资源而不是你选择的语言。我读到GAE是为了与语言无关而构建的,所以可能没有任何语言的内置优势,但是你可以从选择你熟悉和有动力的语言中获得优势。我使用Python,使我的部署更具成本效益的是升级到Python 2.7,只有在使用正确的2.6子集时才能进行升级,这是很好的。所以如果你选择一个你熟悉的语言,很可能你会从使用该语言的能力而不是语言+环境组合本身中获得优势。
简而言之,我推荐Python,但那是我尝试过的唯一的应用引擎语言,也是我选择的语言,尽管我很了解Java,但使用我最喜欢的语言Python,项目的代码会更加紧凑。
我的应用程序规模较小到中等,并且它们几乎不花费任何费用:
英文:
It's probably more about how you allocate the resources than your language choice. I read that GAE was built the be language-agnostic so there is probably no builtin advantage for any language, but you can get an advantage from choosing the language you are comfortable and motivated with. I use python and what made my deployment much more cost-effective was the upgrade to python 2.7 and you can only make that upgrade if you use the correct subset of 2.6, which is good. So if you choose a language you're comfortable with, it's likely that you will gain an advantage from your ability using the language rather than the combo language + environment itself.
In short, I'd recommend python but that's the only app engine language I tried and that's my choice even though I know Java rather well the code for a project will be much more compact using my favorite language python.
My apps are small to medium sized and they cost like nothing:
答案5
得分: 0
我没有使用过Go,但我强烈怀疑它加载和执行实例的速度会更快,并且使用的内存会更少,纯粹是因为它是编译的。根据小组的经验,我相信Python比Java更具响应性,至少在实例启动时间上是这样。
实例的加载/启动时间很重要,因为当您的实例受到超过其处理能力的请求时,它会启动另一个实例。这会导致该请求花费更长的时间,可能给人一种网站总体上速度较慢的印象。Java和Python都需要启动它们的虚拟机/解释器,所以我希望Go在这方面的速度会快上一个数量级。
还有一个问题-现在Python2.7可用,Go是唯一的单线程选项(具有讽刺意味的是,Go被设计为一种现代的多进程语言)。因此,虽然Go请求应该处理得更快,但一个实例只能按顺序处理请求。不过,我会对这个限制持续很长时间感到非常惊讶。
英文:
I haven't used Go, but I would strongly suspect it would load and execute instances much faster, and use less memory purely because it is compiled. Anecdotally from the group, I believe that Python is more responsive than Java, at least in instance startup time.
Instance load/startup times are important because when your instance is hit by more requests than it can handle, it spins up another instance. This makes that request take much longer, possibly giving the impression that the site is generally slow. Both Java and Python have to startup their virtual machine/interpreter, so I would expect Go to be an order of magnitude faster here.
There is one other issue - now Python2.7 is available, Go is the only option that is single-threaded (ironically, given that Go is designed as a modern multi-process language). So although Go requests should be handled faster, an instance can only handle requests serially. I'd be very surprised if this limitation last long, though.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论