This is a single archived entry from Stefan Tilkov’s blog. For more up-to-date content, check out my author page at INNOQ, which has more information about me and also contains a list of published talks, podcasts, and articles. Or you can check out the full archive.

Jens Krämer: Experience with JRuby on Rails

Stefan Tilkov,

These are my live notes from Jens Krämer's talk on JRuby on Rails at Rails-Konferenz 2008.

  • Not talking about ferret and full text search for a change :-)
  • Germany's 1st JRuby on Rails project, started in Dec 2007
  • JRuby 1.8.6 compatible – no problems w/ incompatibilities in his project
  • Recommendation: Cherry as a wrapper for Swing if one is serious about GUI development
  • Differences in JRuby: native threads, GC, Unicode, JIT
  • JRuby benefits: runs everywhere, politics, performance
  • It is possible to deploy a Rails app as a .war, even in practice
  • Performance of Rails on Ruby and JRuby almost identical based on his experience
  • Development done with JRuby and Webrick
  • Test and production on JBoss
  • JNDI Datasources as a benefit for admin/deployment
  • Mongrel/Java considered exotic – why do JRuby when not deploying to a Java web server?
  • JRuby-Rack bridges between servlet engine and Ruby and can run both Merb and Rails apps
  • Project context: Medienservice Sachsen
  • Media/PR handling for the German state of Saxonia
  • External performance and load testing
  • Live since April 08
  • Features
  • Historical correctness
  • Scheduled publication
  • Emailing to journalists (PDF, plain text, html, xml)
  • Personalisation
  • Asynchronous background process to handle mail delivery (including early releases of time-embargoed news)
  • Main problem: migration
  • Old application: WebObjects/Java
  • 4 WO applications, Oracle backend w/ lots of views and stored procedures
  • Goal: centralization to eGovernment Platform, based on JBoss and Apache, Oracle RAC
  • DB Schema had to be kept, including Latin-1 data
  • Functional equivalence
  • Having tests performed by external company was an excellent experience
  • Initial phase: Grails considered. Didn't work out; reasons: Grails is very different from Rails, relies on Hibernate, had many bugs (Autumn 2007)
  • Using Hibernate meant having to write lots of XML config to match the existing database schema – learning curve way too high (no previous Hibernate experience)
  • Didn't like GSP (Groovy Server Pages)
  • Might have changed now
  • Decision to use Rails
  • Three separate applications: frontend, backend, mail handling
  • ActiveRecord was easily flexible enough to handle the existing schema – configuration possible
  • Specific models for existing views
  • Models for more than one table/view (in case of filters)
  • Many plugins
  • Scheduling: handled via Cron in original version; BackgrounDrb was not an option
  • Usage of Quartz scheduler (Rails plugin at https://projects.jkraemer.net/svdn/plugins/jruby/quartz_rails) [very cool!]
  • Logging: log file handling didn't work because of concurrent access from multiple threads
  • Log4J integration for Rails: https://projects.jkraemer.net/svdn/plugins/jruby/log4j_logger
  • ServletContextListener changes default logger
  • Oracle-specific stuff: transparent app failover only works with OCI
  • Blob handling via JDBC streaming (manual JRuby coding)
  • Nice pattern: high-level Ruby to script low-level Java libs
  • Java Advanced Imaging API for thumbnails
  • Apache FOP for XSLT
  • Java-based clustered caching was considered, but not used: filesystem-based fragment caching
  • to_java_bytes and from_java_bytes as conversion for usage of e.g. ByteArrayInputStreams
  • mod_jk problems (not related to Rails)
  • Requirements: 60 parallel users (with real, not artificially high load), no page returned in more than 3s
  • 50-60 requests per second in a VM on a quad core box
  • Summary
    • no problems with inaccessible target production environment - benefit of mature Java platform
    • local development w/ Webrick and local JBoss
    • JRuby and Rails absolutely production-ready
    • Customer was "tricked" into JRuby, but is happy - now asking for ways to more, even without JBoss :-)
    • Tests take too long because of JRuby startup time
    • No attempt to do development/test with CRuby/MRI because of Java dependencies

Q&A:

  • Effort: 4 months, mostly one person (him).
  • Reason for whole project: eGovernment initiative/centralization on JBoss/Apache
  • Is JRuby an option for people w/o Java background: absolutely yes, although some choices might end up differently

Great talk!

On June 10, 2008 12:23 PM, John said:

links :

http://projects.jkraemer.net/svn/plugins/jruby/log4j_logger

http://projects.jkraemer.net/svn/plugins/jruby/quartz_rails

cheers.

On June 10, 2008 3:12 PM, Lars Fischer said:

So what is the point of Grails when us still need to learn Hibernate?

On June 10, 2008 10:33 PM, Arun Gupta Author Profile Page said:

You can also consider using GlassFish for deploying Rails applications - natively or WAR-based. See more details at:

http://blogs.sun.com/arungupta/tags/rubyonrails

On June 10, 2008 10:37 PM, Stefan Tilkov Author Profile Page said:

@Lars: This was interesting to me, too – I often heard the claim that having Hibernate at your disposal is great if you have a legacy DB scheme. In Jens’s experience, using ActiveRecord was even easier (although he quickly pointed out he was new to Hibernate).

On June 10, 2008 11:00 PM, Stefan Tilkov Author Profile Page said:

@Arun: Good point. In addition to Glassfish and JBoss, we’ve also deployed JRuby apps to Tomcat and Jetty without any problems.

On June 12, 2008 11:10 AM, Leif said:

So, what is this Cherry that is being mentioned as a Swing wrapper? I can’t find anything on it.

On June 12, 2008 11:20 AM, Stefan Tilkov Author Profile Page said:

I took notes while he was presenting, that’s why I misspelled it: It’s actually “Cheri”, more at http://cheri.rubyforge.org/

On June 16, 2008 2:22 PM, Leif said:

Thanks! :)

On January 15, 2009 8:09 AM, manmay said:

hello, I am trying to create a Jruby on rails app. with hibernate as back-end and rails as front-end. But i m not able to have hibernate configured for my app . can u please tell me how did u implement hibernate into u’r app. where to have jars,servlet.xml, web.xml, pojos, controllers , models, etc .. i m not able to understand the dir structure of the app….. help me out ..

thanks, manmay [email protected] [email protected]