54

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)

Per Arneng
  • 2,100
  • 5
  • 21
  • 32

5 Answers5

48

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.

proppy
  • 10,495
  • 5
  • 37
  • 66
  • 3
    sounds interesting... got any stats to support these assertions? – Anentropic Apr 27 '12 at 13:00
  • 4
    I don't know about stats, but I think he probably knows what he is talking about given that he is part of the Google App Engine team. For memory consumption you can see here: http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=go&lang2=python3 (but that is python3, and is not clear how closely that applies to GAE) – uriel Apr 28 '12 at 20:48
  • I appreciate that and wasn't being sarcastic, we have problems with large Python apps on GAE where the platform [goes through random periods of crapness](http://code.google.com/p/googleappengine/issues/detail?id=7133) exacerbated by the large number of module imports that need to be done on a cold instance. Seems like having just a single executable to load might help. But without stats of real web apps running on GAE any improvement is just speculation. – Anentropic Apr 30 '12 at 10:24
  • 4
    Here is more detail using 2 non trivial sample app: 1 python app w/ 2 dependencies (google apis, and mapreduce API) consume 50MB on average and take 15s to start. Another Go app w/ 1 dependency (google apis) consume 8MB on average and 1.5s to start. – proppy May 02 '12 at 11:43
23

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)
Peter Recore
  • 14,037
  • 4
  • 42
  • 62
17

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?

stickfigure
  • 13,458
  • 5
  • 34
  • 50
  • AFAIK, the Go runtime does treat individual requests as goroutine on a shared instance (i.e: if a goroutine is blocking on I/O, another 1 can process an incoming request) – proppy May 02 '12 at 11:28
  • If that is true, I need to revise my answer. However, I can't find any official documentation on the matter. Can you point me in the right direction? – stickfigure May 02 '12 at 16:16
  • There is a recent thread about that on the official google-appengine-go group: https://groups.google.com/d/msg/google-appengine-go/3qEIZHRaLN8/Me7aS7E-kfAJ – proppy May 03 '12 at 13:50
  • Thanks Johan - I've corrected the answer. It would be great to have this kind of macro-scale behavior officially documented somewhere. – stickfigure May 07 '12 at 19:05
1

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:

enter image description here

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
  • 1
    the major difference with python 2.7 was the ability to have one runtime handle multiple threads, correct? This presumably allowed you to run less instances? – Peter Recore Nov 07 '11 at 18:40
  • I believe it is today the new pricing takes effect. So I can post my updated details running python 2.7 to get the estimate what I save from having the upgrade done. – Niklas Rosencrantz Nov 07 '11 at 20:16
0

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.

FoxyLad
  • 1,616
  • 11
  • 12
  • Even if Go runtime is single-threaded, it does support handling concurrent request w/ Go routines. They don't execute in parallel, but if a goroutine is doing I/O, another one can handle an incoming request. – proppy Apr 23 '12 at 14:58
  • 1
    I believe Go runtime is no longer single-threaded, I have a map tile application with a few users heavily loading tiles at the same time, and only 1 instance is used all the time. – user7180 Sep 07 '13 at 01:24