My RailsConf Europe Mini-Keynote

Posted by Nick Sieger Wed, 10 Dec 2008 14:50:44 GMT

Here’s a nice surprise. My mini-keynote at RailsConf Europe was posted over at It’s only 10 minutes, so give it a watch and let me know what you think. I even watched it myself, without cringing! I laughed (at how I actually sounded credible), I cried (at how I laughed at my own poorly-delivered joke).

Tags ,  | 1 comment

JRuby Q & A at RailsConf

Posted by Nick Sieger Sun, 01 Jun 2008 22:07:33 GMT

These are the notes I took during our “panelish” Q & A session on Sunday afternoon at RailsConf.

  • Exceptions (behavior between ruby and java)

    • Embedding: JSR-223 preferred, BSF fallback
  • Java integration, mocking, proxying, extension

  • Multiple VM support

    • multiple JRuby instances can be run in the same VM
    • JavaSand (google it) -- Ola’s port of _why’s (freaky freaky) sandbox
  • Startup time performance gain recently

    • -Xbootclasspath: VM does not verify classes in the “boot” classpath
    • -Xverify:none is not recommended because of runtime-generated code
    • Nailgun to keep VM running and “send commands” to it
  • Compiling Ruby code to JVM bytecode

    • Keep # of class files low
    • Walk AST and dump out high-level, abstracted operations (local variable access, dynamic invocation) and low-level bytecode is built for each of those
    • 4096 -- maximum # of methods to be compiled
    • Compiled methods are shared between runtimes
    • Future:
    • raise/eliminate overhead of compiled methods
    • share AST, reduce memory load
  • Community tasks/actions

    • Projects needing help (e.g., ActiveHibernate)
    • Adoption, acceptance, blogging
    • Documentation ( and others), screencasts
    • Who’s using it?
  • Sun’s commitment

    • Ruby vs. Groovy vs. Python vs. Scala vs. other langs
    • Rails vs. Grails vs. Lift vs. JSF vs. Struts 2 vs. ???
    • all of the above
    • improve the JVM’s support for all dynamic languages
    • JRuby is a full open source project, not owned or controlled by Sun, with history that extends years before main devs hired by Sun
  • Ruby programming language, JRuby is an implementation

    • community evangelism of Ruby the language vs. implementations
    • despite MVM, FFI and emerging areas that are not standard yet
  • How do you pitch JRuby/Rails in a legacy environment?

    • Consider demonstrating running application without discussing technology specifics
    • IBM and JDK 1.5 issues have been reported
    • Free support as long as these issues are new and help improve JRuby and the community!
  • Testing

    • JRuby enables more agile testing
    • Without production risks
    • Ceremony vs. Essence discussion
  • Terracotta/DSO

  • Windows/Mongrel/ImageMagick issues

    • ImageVoodoo is an imaging library using Java2D, comes with Java
    • MiniMagick also reportedly works
  • Rails benchmarks

    • Micro-benchmarks are problematic and usually don’t lead to measurable application speedups
    • Community needs a real-world, full application
    • Antonio Cangiano working on new application-level benchmarks?
    • “Richards” -- Smalltalk-originated application benchmark
  • JSR-292 (“invokedynamic”)

    • Actually extension of “invokeinterface” bytecode
    • Call site structure/method handles
    • Expose the dynamic nature of the JVM (get the Java-specific stuff out of the way)
    • Language-specific calling semantics, method invocation
    • “Punching a hole” through the JVM
    • Comments on JSR-292 Early Draft Review currently ongoing

Tags , ,  | no comments

RailsConf slides

Posted by Nick Sieger Sat, 31 May 2008 23:42:00 GMT

If you already saw my JavaOne slides, these aren’t too different, but I think they’re better and prettier, too.

JRuby at RailsConf

Get them here.

Update. The slides are pretty lean on explanation. Just in case you’re confused, the narrative goes like this:

  • What’s your deployment nirvana look like? (various existing options)
  • With JRuby, you can deploy Rails applications in a single operating system process instead of many.
  • However, there are a few configuration changes needed to accomodate JRuby. (Steps for converting existing apps, configuration code snippets.)
  • Now, JRuby-Rack helps with the configuration, because all of the logging/session/public path re-jiggering is taken care of for you. It’s now bundled with Warbler as of version 0.9.9.
  • Performance is good and getting better. You can scale up the number of requests you can handle really easily just by setting the number of runtimes to create inside Warbler’s config/warble.rb file.
  • Lots of new stuff is happening right now to make Rails better. JRuby will be able to leverage these changes and become an even more desirable deployment platform. Stay tuned!

Tags , ,  | 3 comments

JRuby Hackfest at RailsConf

Posted by Nick Sieger Thu, 22 May 2008 15:40:00 GMT

Thanks to our friends at LinkedIn, Joyent and Sun, we’re having a hackfest at McMenamins/Kennedy School on Thursday evening, May 29, starting at 6:30pm, complete with food and beverages!

Do stop by and hang out with us! Leave a comment over at Charlie’s announcement if you’re interested in joining us.


Kennedy School
Local: (503) 249-3983
Elsewhere: (888) 249-3983

View Larger Map

Tags , ,  | no comments

Spring and Summer Gigs

Posted by Nick Sieger Fri, 18 Apr 2008 17:25:16 GMT

Just a quick note on some upcoming gigs. I’ll be speaking next month at both JavaOne and RailsConf, giving an update on the JRuby deployment situation, which by the way is rapidly improving! Despite my proposal for a hands-on tutorial on JRuby deployment not getting accepted for RailsConf, I’ve been asked to fill one of the Sun-sponsored talk slots again. So, much like RailsConf EU last fall, if you come listen I promise you will not get a heavy sales pitch from me! Do stop by, I may even have a couple goodies in store for you.

I also feel privileged to be speaking at RubyFringe this summer, where I haven’t yet determined exactly what I’ll be talking about (although it will probably have some connection to JRuby).

Hope to see you at one of these upcoming events!

Update: We just re-jiggered the schedule of 3 JRuby-related talks at JavaOne, including mine, so that they flow better from beginning to end of the week. My talk is now on Thursday morning instead of Wednesday morning. In addition, Charlie and Tom’s is on Tuesday, and Ola’s is on Wednesday. If you’re attending JavaOne and are interested in JRuby-related talks, please make sure you log into Schedule Builder and re-check your schedule.

Tags , , ,  | 2 comments

RailsConf Europe: Hydra

Posted by Nick Sieger Sat, 06 Oct 2007 12:04:00 GMT


On September 19, Craig and I presented our talk at RailsConf, which appears to have been well received. It went off mostly without a hitch, if it wasn’t for a couple of hiccups in the demos. I apparently didn’t practice them enough, because a couple of critical steps were either missed or I did them out of order and confused myself. But that’s ok, because I’m releasing the demo steps, source and slides here so you can try them out for yourself.

So, download the zip and follow along. The contents look like this:


The demo steps are in the text files; I’d recommend going in the order specified. It turns out the third isn’t really a demo but more of a code review, because it also requires you to have Roller set up and I’m not going into those details for now. If you want to just run the demos, skip to demo-baked, the finished product.

For those of you who didn’t see the talk, here’s the basic message.

Look at your basic MVC Rails app.

Single app

Why not consider spliting it into two? ActiveResource allows you to access a RESTful resource in your Rails application like it was just another model.

Double app

This might seem like overkill for a simple application, but what if you had an e-commerce application domain like this?

E-Commerce app

Splitting up your code into separate Rails applications encourages encapsulation, reduces potential coupling, and gives you more flexible deployment options. Basing interactions upon REST and HTTP means that you can more easily mash up data or create caching strategies, given proper usage of ETags/Last-Modified and/or cache-control headers. The great thing is that existing HTTP reverse proxies can be used without having to mix the caching code in with your application code.

In the application we’re building, we have a number components that are not Rails-based. To expose them to our environment, we’ve taken the strategy of exposing a simple REST web service for the component, and then it can be consumed by the other applications using ActiveResource. The REST web service can either be implemented in the component’s native language/technology, or in some cases we’ve written a wrapper service in Rails since Rails makes it so easy to build REST interfaces. In that case, Rails is pure integration -- RESTful glue.

The idiom that makes this all possible is the uniform interface. In HTTP, this means addressability (each resource gets a unique URI) coupled with the HTTP method verbs HEAD, GET, POST, PUT, and DELETE. Inside your Rails applications, it’s the ActiveRecord interface. If you keep your controllers skinny, you can boil the interface down to the following set of methods (in this case, for the prototypical blog post model):

And in fact, this is precisely what ActiveResource provides, and it’s enabled by duck-typing. Walking through the demos illustrates this pretty well, as you’ll basically swap ActiveRecord for ActiveResource with no noticeable difference, all the way down to validation errors in the scaffolded forms (which I was unable to demo in the talk due to the hiccups).

We’ve found that when you’re making RESTful web services, the controllers largely become boilerplate because of the uniform interface. make_resourceful has been a boon in that regard, as the demos also show. There are several plugins that help you DRY up your controllers (other approaches include resources_controller), so you have some choices there.

We mentioned some drawbacks in our experience with ActiveResource, which have largely been addressed for the upcoming Rails 2.0 release.

Finally, we noted that deployment could be a pain with so many Rails applications to keep running. To that end, we are leveraging JRuby and Glassfish to make this a non-issue, as we simply WAR up our Rails applications with warbler and let Glassfish take care of the rest. Performance is still an open question, but we plan to roll up our sleeves and make sure this combination really hums.

Enjoy the demos! Feel free to drop me an email if you have any questions or troubles with them.

Tags ,  | 5 comments

RailsConf Europe: David Heinemeier Hansson

Posted by Nick Sieger Tue, 18 Sep 2007 08:14:00 GMT

Rebel With a Cause

Rails is no longer the James Dean character, looking outward, trying to convince you of something. It’s no longer about a rebellion or a revolution. Instead, Rails is settling in as a passionate, inward-looking craftsperson.

After the rebellion, settle in and enjoy the results of your work. David hasn’t been working directly on Rails too much, instead he’s been enjoying it.

And it’s not about David anymore. It’s about You (cue the Time Person of the Year cover). David wants Rails to be more friendly to newcomers.

Report #12: Verified Patches. Encouraging the community to approve patches, rather than limiting the decisions to the core. Opening up Rails. (Also, unfortunately looking a little scarce at the moment. Update: turns out it’s empty because patches are quickly applied, not because there aren’t any submitted!)

David screened the original Rails movie -- showing Apache setup, manually creating databases and tables. He quickly lost patience for it.

Compare to the current state of the art, with everything down to the routes and migrations gets created for you, lowering the barrier to entry (example: a new rake task db:create:all).

Rails 2.0 is largely about continual improvement and removing the cruft:

  • Cookie-based session store as the default
  • Routing: map.root
  • Removing the dynamic scaffold :posts feature
  • map.namespace and script/generate controller admin::posts
  • *.html.erb files with the MIME type and renderer baked into the filename, since the two are now mutually exclusive.
  • Automatically named partials with render :partial => @posts resolving to _post.html.erb
  • Namespacing and named routes:
mop.namespace :admin do |admin|
  admin.resources :posts
# ...
link_to 'Show', [:admin, post]
  • HTTP authentication
class Admin::PostsController < ApplicationController
  before_filter :ensure_administrator
  # ...
  def ensure_administrator
    authenticate_or_request_with_http_basic("Blog Admin") do |user,pass|
      username == "dhh" && password == "123"
  • Custom layouts for specific user agents (say, oh, the iPhone). Views can also be rendered, e.g., index.iphone.erb.
class ApplicationController < ActionController::Base
  before_filter :adjust_format_for_iphone

  def adjust_format_for_iphone
    if request.env["HTTP_USER_AGENT"][/iPhone/]
      request.format = :iphone

# initializer
Mime::Type.register "application/x-iphone", :iphone

# In a controller method
respond_to do |format|
  format.iphone { render :text => "Hello iPhone", :content => Mime::HTML }
  • atom_feed_helper, a new plugin -- builder for Atom specified in index.atom.builder
  • <%= yield :head %>, content_for :head { auto_discovery_link(:atom, formatted_posts_url)}
  • Debugger -- allows you to be lazy and leave your breakpoints in your production code, not that you’d actually want to do that. Dumps you into irb where you can inspect variables, etc. but you can also drop down another level to see the call hierarchy, etc.

So when will we see Rails 2.0? The preview release is coming, hopefully before conference end.

Tags ,  | 6 comments

RailsConf Europe: (Prag-) Dave Thomas

Posted by Nick Sieger Tue, 18 Sep 2007 08:08:34 GMT

(Written from Dave’s perspective, in the first person, but paraphrased)

What is a relevant topic in Germany? Engineering. Except there’s no such thing as software engineering. The software equivalent of building a bridge is taking a whole lot of dirt that fills in a hole.

So what makes engineering good? I look for elegance and beauty.

Fred Brooks -- Mythical Man-Month. Not a single thing in software engineering has changed in the 30 years since the book was written. Go out and order it tonight if you haven’t read it.

We are privileged, because we get to start with nothing. Anything we can conceive of, we can create. And so, we suffer the same problems as poets suffer.

Writer’s block: a blank page standing in the way of getting started. Painting: a blank canvas without structure or form. Software project: a blank editor buffer.

Leonardo was commissioned to build a statue. But, having never bronzed in his life, he picked up a scrap of paper and drew sketches. He’s prototyping on paper, but in reality he’s prototyping in his mind, getting his brain thinking about what he’s doing.

We could do more of this experimentation. Whiteboard, index cards, we eschew them for scaffolding or other crutches. But we could think of more ideas if we got away from the familiar and tossed around new, fresh ideas.

The idea that we sit down and start coding the application is crazy. We don’t know what it’s supposed to be. Why should we fool ourselves into thinking that this works?

Artists draw cartoons, often a fully rendered version of a painting. If they don’t like the cartoon, it survives, but the final product probably takes a different form.

With Rails we can do rapid end-to-end prototyping. Scaffolding helps with this, and it probably won’t make it into the end result.

So start anyway, and be prepared to throw it away. Write tests, use them as tracer bullets. And act on worry. Listen to the inner voice that tells you when something is wrong.

Sistine Chapel: brilliant example of modularization. It shows you how to conceive of doing a huge project without the fret of focusing on the entire thing.

Another example: comic books. You’re splitting up the product into time slices. Limit how much you do, and leave open the possibility of continuing at a later day. Know when to stop.

Satisfy the customer. Compare portraits to pictures. The best portraits, while not always faithful to the real image of the subject, still achieve the goal of satisfying the customer.

There is art in engineering, and engineering in art. Neither is an either/or proposition. Art and engineering are mutually supportive, in that you can’t have one without another.

With Ruby and Rails, we have a responsibility to uphold. Rails is a canvas, so be an artist. Create something great. But we also should create something beautiful. Sign your name by your work, and take pride in it.

Tags ,  | 3 comments

Gig: Speaking at RailsConf Europe 2007

Posted by Nick Sieger Fri, 14 Sep 2007 05:33:00 GMT

Speaking of keeping busy, I’ll be speaking alongside my colleague Craig McClanahan at RailsConf Europe in Berlin next week.

Sun is a Diamond Sponsor at RailsConf again, just like in Portland last May. Part of that sponsorship money pays for a brief keynote spot (filled by Craig) as well as a session or two. So no, I didn’t get my spot through an accepted proposal submission, but that doesn’t mean that the session is going to be a big marketing shill.

No, actually Craig and I are part of a small group at Sun that’s embracing Rails in a big way, and we’re going to be launching a site built mostly on Rails later this fall. We’re taking what we think are some novel approaches to building a Rails-based application and we thought we’d share some of those thoughts with you rather than drone on for the session about how great Sun is and what snazzy tools we make. (Although expect to see a subtle plug or two for Sun hardware and tools. Call it product placement rather than overt selling.)

I titled the session “Rails Hydra” because the central idea of the structure of our application is not one Rails app, but many. The UI and views don’t even talk to a database; instead they make use of ActiveResource and RESTful web services, talking to the models living in other Rails applications in the backend. One key point is we’re deploying .war files to JRuby running on Glassfish, thus avoiding headaches of morbidly multiplying Mongrel math. We’ll elaborate on this arrangement and talk about some of the other tools and tricks we’re using.

Also, Charlie, Tom and Ola will be there, so we’ll certainly have a JRuby summit at some point. Stop by and say hello!

Posted in  | Tags , ,  | 1 comment

RailsConf 2007: Chris Wanstrath: Kickin' Ass with Cache-fu

Posted by Nick Sieger Sat, 19 May 2007 20:34:00 GMT

Chris is here to talk about games, since he used to work for Gamespot. He coded PHP, which is like training wheels without the bike. He had to sit in a glass cube and help keep the site running during E3 last year. There were 100 gajillion teenage boys during their lunch break hitting refresh, and it all blew up. Couldn’t even gzip the responses, because the servers heated up to much. They served 50M pages in a day, without downtime. They did it with Memcache.

Memcache is a distributed hash -- multiple daemons running on different servers. Developed by Livejournal for their infrastructure, you just put up the servers, and they just work.

Should you use Memcache? No. YAGNI, UYRDNI (unless you really do need it).

Rails and Memcache

Fragments, Actions, Sessions, Objects, cache it all. You can use:

  • memcache-client (by Robot-coop guys/Eric Hodel). Marshal.unload is 40 times faster than from the database.
  • CachedModel -- integration with ActiveRecord
  • Fragment Cache Store
  • Memcache session store



Or, acts_as_cached. It knows about all the aforementioned objects, with a single YAML config file (config/memcached.yml). Word to the wise: don’t use names in your server config file. Use IPs, avoid BIND and connections to the servers with every connection. Don’t let DNS outages bring down your servers.

  • get_cache
  • expire_cache

This is all you need -- if you’re using set_cache, you probably don’t understand how the plugin works. Expire cache on the “after save” hook, which allows you to cache ID misses as well.

class Presentation < ActiveRecord::Base
  after_save :expire_cache

Example: only cache published items

class Presentation < ActiveRecord::Base
  acts_as_cached :conditions => 'published = 1'

Cached-scoped-finders (if somebody thinks of a good name, let Chris know). The idea is to move custom finder logic to a method on your model, and then wrap a cache-scoping thingy around it. cache_fu ties this up nicely by giving you a cached method on AR::Base.

class Topic < ActiveRecord::Base
  def self.weekly_popular
    Topic.find :all, ...


Adding date to cache key with alias_method_chain:

def self.cache_key_with_date(id)

class << self
  alias_method_chain :cache_key, :date

Cached loads by ID: Topic.find(1, 2, 3) moves to Topic.get_cache(1, 2, 3), which can parallelize calls to memcached and bring them back as they’re ready.

user_ids =
@users = User.get_cache(user_ids)

You can also cache associations, so that you’re navigating associations via Memcache.

Cache overrides

class ApplicationController < ActionController::Base
  before_filter :set_cache_override
  def set_cache_override
    ActsAsCached.skip_cache_gets = !!params[:skip_cache]

reset_cache: Slow, uncached operations can sometimes queue up and wedge a site. Instead, issue cache resets on completion of a request, rather than expiring beforehand. That way, requests that continue to pile up will still use the cached copy until the rebuild is complete.

class Presentation < ActiveRecord::Base
  after_save :reset_cache

Versioning: a way to expire cache on new code releases

class Presentation < ActiveRecord::Base
  acts_as_cached :version => 1

Deployment: Chris recommends using Monit to ensure your Memcache servers are up.

libketama: consistent hashing that gives you the ability to redeploy Memcache servers without invalidating all the keys.

Q: Page caching? A: Nginx with native Memcache page caching, but outside of Rails domains.

Lots of other questions, but dude, Chris talks too fast!

Tags ,  | 2 comments | no trackbacks

Older posts: 1 2 3