Nick Sieger: Tag google tag:blog.nicksieger.com,2005:Typo Typo 2010-11-22T18:06:58+00:00 Nick Sieger urn:uuid:32ea8753-bf86-4fe8-bec2-4b2f432512fe 2009-04-11T04:10:51+00:00 2010-11-22T18:06:58+00:00 JRuby on Google AppEngine: First Impressions <p>I was surprised by <a href="http://googleappengine.blogspot.com/2009/04/seriously-this-time-new-language-on-app.html">Tuesday&#8217;s announcements</a> as much as anyone else&#46; <a href="http://olabini.com/blog/2009/04/jruby-on-rails-on-google-app-engine/">Ola keeps secrets well</a>&#46; He sent me a pull request for <a href="http://jruby-rack.kenai.com/pages/Home">jruby&#45;rack</a> just last week mentioning &#8220;some restrictive environments where you can&#8217;t start threads&#8221;&#46; I didn&#8217;t blink, and instead just merged his patch&#46;</p> <p><img src="http://rubyonrails.org/images/rails.png" alt="rails"/> <img src="http://2.bp.blogspot.com/_dLfQMJsmsaI/SdvwPx8hz5I/AAAAAAAAACY/I_DEfn6nQjc/s320/ae_gwt_java.png" alt="java-gae"/></p> <p>Despite the surprise news, it turns out my timing wasn&#8217;t bad&#46; <a href="http://twitter.com/nicksieger/status/1189629742">Just a couple of weeks ago I was experimenting</a> with the Python version of AppEngine, just to see what the fuss is all about&#46; Even though Google&#8217;s had its <a href="http://radar.oreilly.com/archives/2008/04/is-google-app-engine-a-lockin.html">share</a> of <a href="http://www.tbray.org/ongoing/When/200x/2008/04/09/Google-Users-API">criticism</a> for building a platform that is difficult for developers to leave, the lock&#45;in aspect didn&#8217;t bother me&#46; I&#8217;m a pragmatist first, and I believe that we as developers are the only ones locking ourselves to a platform&#46; We have a choice, after all&#46; And look at <a href="http://www.nytimes.com/2009/04/05/fashion/05iphone.html">all the developers willfully rushing</a> to develop Cocoa applications for the iPhone&#46; The fact that their code is not useful on any other device isn&#8217;t stopping them&#46;</p> <p>The thing with AppEngine is that it&#8217;s a unique platform all unto itself&#46; That may seem brutally obvious, but the point seems to be lost in all the frenzy surrounding the Run&#45;Rails&#45;Struts&#45;Spring&#45;Groovy&#45;Grails&#45;Lift&#45;You&#45;Name&#45;It&#45;Framework on AppEngine this week&#46; I&#8217;m not saying it&#8217;s a bad idea to try to run Rails on AppEngine; quite the contrary&#46; I&#8217;m saying you need to be honest about the trade&#45;offs and constraints&#46; And in the case of Ruby and Rails, boy are there a bunch of them:</p> <ul> <li>No regular <code>net/http</code>, <code>restclient</code>, <code>ActiveResource</code> usage&#46; Google has a URL fetch library, and has hooked up Java&#8217;s <code>HttpURLConnection</code> to it, but none of the Ruby URL&#45;fetching libraries use it&#46;</li> <li>No ActiveRecord&#46; &#8216;Nuff said&#46; For some folks, that&#8217;s a welcome change, but wrapping your head around AppEngine&#8217;s BigTable&#45;backed data store takes some thought&#46; You just can&#8217;t view it like a SQL engine&#46;</li> <li>No RMagick/ImageScience/attachment_fu&#46; No <a href="/articles/2008/03/27/imagevoodoo-0-1-released">ImageVoodoo</a> even (no javax&#46;image APIs)&#46; Google has it&#8217;s own image manipulation API&#46;</li> <li>Startup/first request processing time is currently an issue&#46; It&#8217;s not clear yet how long Google keeps JVMs warm, so if your application is idle, the first few hits to it return 500 errors&#46; I can only assume Google has a plan to address this&#46;</li> <li>Crypto&#46; Although java&#46;security and javax&#46;crypto APIs are apparently <a href="http://code.google.com/appengine/docs/java/jrewhitelist.html">whitelisted</a>, I haven&#8217;t had time to figure out how to leverage them&#46; JRuby&#8217;s jruby&#45;openssl gem does not work, which means things like <code>digest</code> aren&#8217;t available&#46; That&#8217;s currently a blocker for Rails&#8217; cookie session store&#46;</li> <li>1000&#45;files limit per application&#46; In order to work around this, I ended up <a href="/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar">jarring up all the Rails gems</a> when deploying a Rails application&#46;</li> </ul> <p>These are just a sampling of some of the problems you&#8217;re dealing with on the AppEngine frontier&#46; They&#8217;re all solvable; it will take a little time and BST (blood, sweat and tears)&#46; The point is you can&#8217;t expect a Rails application on AppEngine to behave like all the Rails applications you&#8217;ve written previously&#46;</p> <p>In return for your troubles, you get the AppEngine value proposition, which is actually attractive in a lot of ways: Google runs the platform&#46; You don&#8217;t have to worry about it&#46; Transparent scaling, monitoring, logging, everything below your application code is taken care of&#46; Single&#45;step deployment, with application versioning and rollback&#46; Scalable services: BigTable storage, memcached, scheduled tasks&#46; My friend <a href="http://googleappengine.blogspot.com/2009/02/best-buys-giftag-on-app-engine.html">Curt Thompson of Best Buy&#8217;s Giftag&#46;com</a> talks about how they leverage AppEngine for a non&#45;toy application&#46; (Curt also helped me get my <a href="http://nicksieger-notes.appspot.com/">Python AppEngine experiment</a> up and running&#46;)</p> <p>In the end, I&#8217;m still extremely excited about the prospect of using JRuby and Rails on AppEngine, and can&#8217;t wait to see what people build with these tools&#46; If you want a little head start, you can check out the first Rails application I deployed, <a href="http://jruby-rack.appspot.com/">jruby&#45;rack&#46;appspot&#46;com</a>&#46; The &#8220;application environment&#8221; page is the main dynamic action in the app, which just enumerates a bunch of request and system environment properties so you can get a feel for how things are set up in the AppEngine Java environment&#46; The source code for the application is linked from the front page&#46; Note that the app was deployed with JRuby trunk and <a href="http://kenai.com/projects/jruby-rack/lists/talk/archive/2009-04/message/0">JRuby&#45;Rack 0&#46;9&#46;4</a>; Warbler is not yet using these components but you can build them yourself, drop them in and try them&#46; We&#8217;ll be updating JRuby, Warbler and other tools soon to make this process more seamless soon&#46; Stay tuned!</p>