Monday, November 2, 2009

Google App Engine 0.0.5 gems released

We're excited to release the 0.0.5 google-appengine gem. The main focus of this release is on performance. If you've used Ruby on App Engine you know that the biggest pain point is start up time. Traditional Ruby app servers are designed to load everything your app could possibly need into memory, before responding to incoming requests. This model works with the assumption that machines are pre-allocated and can sit idle waiting for traffic. With App Engine, instances of your app spin up or down as needed to meet the given load at any time. This means that your applications require less CPU because less is idle, but it also means your app initializes new instances far more frequently. Whenever this happens, the first request seems to hang, potentially for many seconds, as the application initializes. We've made a few changes to make this less painful:
Gem Bundler - Loading RubyGems takes several seconds, so we've dropped support for RubyGems. Instead we're using the lighter-weight Gem Bundler. Instead of the `appcfg.rb gem` command, you now use a Gemfile. We generate a skeleton one for you, so just add your dependencies and you're good to go. Versions of Rails that require RubyGems are no longer compatible with these tools, but we expect to have Rails 3.0.pre working shortly.
Precompilation - This is a new, experimental feature of the Java runtime. The Java classes (i.e. JRuby) in your app are precompiled for App Engine when you deploy your app instead of during your request. This means the JRuby runtime should start up several seconds faster. This is a beta feature, so you may need to disable it if you have problems with deployment. See the in the Sinatra demo for an example of using this option.
Hybrid Apps - You've always been able to add Java Servlets and Filters to your to serve part of your app. Previously these handlers would have to wait for JRuby to initialize before they could serve a request. We've tweaked the web.xml we output so that these servlets can now run immediately. So you can write speed critical parts of your app (perhaps a homepage or some simple AJAX request handler) inServlets. In addition to traditional Java Servlets, you can also use Duby. Duby is a new language that shares the Ruby syntax, but compiles to Java bytecode. Charles Nutter covered Duby in his Ruby Mutants session at the Strange Loop Conference. Ryan Brown has been adding features to Duby and has a created a sample App Engine Duby app. As with Java Servlets, Duby Servlets are available right away, without the painful delay associated with spinning up a new instance of the JRuby Runtime.
This release also includes updates to a number of the included packages:
  • JRuby updated to version 1.4.0
  • App Engine SDK updated to version 1.2.6
    • Includes incoming email support.
  • App Engine APIs gem updated to version 0.0.10
    • Bas Wilbers contributed an ImageScience compatible Image API.
  • DM Adapter gem updated to version 0.0.6
    • Now supports all native Datastore types.
    • Associations have hopefully been fixed.
We'd like to thank all the early adopters for forging ahead, despite problems like the spin up delays. We'd also like to thank the users that have been contributing documentation, especially Maksym Parkachov for figuring out how to get the Rack::Reloader to work with Sinatra, and contributing documentation.