Friday, November 11, 2011

Google AppEngine vs. Heroku

Note: most of the restrictions for AppEngine should be resolved with Managed VMs launching soon.

As you might know I'm currently working on my top-secret project, called JOPPFM. It requires some heavy work on the server-side, so choosing the best PaaS / SaaS is critical. At first, I planned to use AppEngine. Unfortunately AppEngine restricts you to use HTTP only, but I need IMAP / POP and XMPP too.
A few weeks ago Heroku introduced support for Java, and I've decided to ditch AppEngine in favor of Heroku, because the easy deployment (using git) and the freedom (use whatever protocols you want, unlimited bandwidth, unlimited database read and writes, etc) fascinated me. So I started developing JOPPFM for Heroku and yesterday I finally managed to get a first prototype up and running.

During development I faced lots of problems and shortcomings of Heroku and decided to migrate to AppEngine after finishing the first prototype. So, here I am. I think I'm now able to compare those two services for you...

Take a look at AppEngine's extensive documentation here. Almost every feature AppEngine offers is described here. Note that this documentation is language-specific! No general blabla, but actual code in the language you're working with.
Heroku offers an extensive documentation too... but not for Java. Almost all official wiki entries are for Ruby. The Java-specific documentation you can find on is their announcement of Java support on their blog, which describes the first steps of getting an app up there. Fortunately one of their employees, James Ward, seems to be a Java developer himself and wrote a great "workbook": "Heroku for Java Workbook".

Still, that's not comparable to what Google offers. Goal for AppEngine.

TL;DRHeroku wins this point. You're allowed to do almost everything! Run threads from servlets, connect to an IMAP server, etc. The only "restriction" I remember at the moment is a timeout at ~60 or 90 seconds on HTTP connections. However, this only counts for idle HTTP connections. Push some data out there every 30 seconds and you're good to go...
So, if you already have a Java server running, you could run it without any modifications on Heroku.
AppEngine is restricted by design. I guess it's for the sake of security and performance. That's a good reason to restrict developers, but I would still love to workaround this somehow...

For this purpose, Heroku offers... erm... nothing? Ok, I have to admit: if I didn't mix up SaaS (which Heroku is) and PaaS, SaaS doesn't offer administration tools by design. That's what it's supposed to do: run your app. Additionally, you have access to your app's output, but that's it.
PaaS however, which AppEngine is, offers you great tools for logging events and errors, measuring your load and performance and so on. AppEngine does that job pretty well. Heroku 1 : AppEngine 2.

Free candy
Both, AppEngine and Heroku offer you some free stuff. Every month, again and again! Basically they offer the same: one instance is free. Additionally, you get unlimited bandwidth and a 5MB (!) database.
The free tier at AppEngine is... different. Take a look at it yourself here.
It depends on your needs which service wins this category.

Storing Data
I'm not sure if I prefer direct access to a (Postgre-) SQL database, or if I prefer a wrapper, like the excellent objectify-appengine. Again, decide yourself...

That's it. I hope you keep these facts in mind for your next app.


  1. Thanks Tom for checking out Heroku! We love getting this kind of feedback! Let me know if you have any questions / problems.

    jw at heroku dot com

  2. My biggest issue with GAE/J was the difference between development and deployment. Tests would run fine on my machine, but the deployed app would not run. In my case this was because of the poorly documented (but definitely by design) limitation of only being able to write to a given entity group a certain number of times per second.

    I agree with you about the documentation. I get confused trying to translate the Ruby stuff to Java. Another example of poor documentation is the module list. The page where they list all the modules tells you their cute names and logos and maybe even a one-line description, but often you can't really tell what's being offered.

    One place where GAE really killed Heroku was in scaling: Heroku forces you to set the number of dynos, but GAE allowed it to vary dynamically using some simple heuristics. Also GAE had an XMPP server. I'd really like to see that in Heroku.

  3. Good point, automatic scaling seems quite good what I've heard so far. But to be fair: Heroku doesn't support that by design. I think there are plugins that do that for you though.

  4. Don't get me wrong, I like Heroku A LOT, but I am not sure why it's being fair to Heroku to say they don't do it "by design." Whether it's by design or not, App engine does it, and does it well, and Heroku does not. As for "plugins," there are some open source packages that claim to "autoscale". From what I understand, none of them work well. Heroscale will do this, but it's unclear to me if that's Ruby only, it's not free. It's not an official module, and it's not the right solution.

    I think the right solution would be to monitor the request queue so new dynos can be launched as soon as they are needed, and extra dynos can be culled when they are no longer needed. This is more or less how app engine does this. Third party code must, instead, constantly poll for performance metrics, which is awkward, and performance draining, in and of itself.

    1. I think that's because AppEngine offers a whole framework, including tools, etc. Heroku is just plain "build and run".