10. RubyGems
• Gems are units of software reuse in the
Ruby world
• Most Gems will work the same in JRuby as
in MRI
• Gems with native code _may_ work, but
seek alternatives
15. Launch Time
• Yes, it can be a problem
• MRI: Quick to start, speed remains constant
• JVM: Slow to start, faster as hotspots are
optimized
16. Launch Time
• What to do about it?
• Tweak startup options to make JVM
startup as fast as possible
17. Launch Time
• JVM Options (prefixed with -J with jruby)
• -client (-J-client)
• -XX:+TieredCompilation
• -Xshare:dump / -Xshare:on
18. Launch Time
• JRuby Options
• -X-C (turn off compilation)
• --ng-server / --ng
• --ng will get faster after several
executions while the JVM optimizes
20. Lab 3: Try it out
• -J-client
• -J-XX:+TieredCompilation
• -J-Xshare:on
• -X-C (turn off compilation)
• --ng-server / --ng
21. Launch Time (cont.)
• Can be improved, but for small tasks
cannot (yet?) match MRI
• What options are left?
• Guard
• Spork
22. Launch Time (cont.)
• Iterate using MRI
• Quickly verify small changes
• Integrate using JRuby
• Less frequent
• May have longer test suites, perhaps more
work, can afford to pay the start up cost
27. Converting Rails App
• Rails itself (aside from ActiveRecord) is
very compatible with JRuby
• Gems used in any given project may or may
not be.
• jruby-lint can help identify potential issues.
28. Converting Rails App
• What are some known issues?
• Some ObjectSpace methods disabled by
default
• Native code use
• Kernel#fork / backtick operator / system
usage
29. Lab 5: Convert an App
• $ cd graphy # Rails app targeting MRI 1.9.3
• If you’ve got MRI installed, look at current
app
• bundle install
• rake db:create db:migrate db:seed
• rails s
31. Lab 5: Convert an App
• After performing the updates, test the app
in JRuby
• Also test the app in MRI, if available
• Having dependencies properly scoped
should allow you to execute the app in
either environment
32. Lab 5: Convert an App
• Have an app along with you? Try
converting it now!
• Install/Run jrlint
• Update Gemfile (if necessary)
• bundle install
• Run your tests/specs or rails s.
• Ask questions!
33. Web App Deployment
• A Rails app is no good without a solid
deployment environment
• MRI deployment strategies leverage MRI
strengths
• Need JVM deployment options to leverage
JVM strengths
34. Web App Deployment
• MRI: HTTP server -> Ruby process(es)
• Mongrel / Unicorn
• Passenger
• JRuby: HTTP server -> JRuby threads
• Rails app: config.threadsafe!
• Be mindful of the threadsafety of your
dependencies
35. Web App Deployment
• Deploying in Java Application Server
• Most self-contained option: WARbler!
• JRuby web app -> deployable WAR
• Other options
• Trinidad / Glassfish Gem
• Torquebox
36. Lab 6: Deploy it
• We’ve ported an app to JRuby. Now
deploy it!
• $ gem install warbler
• $ warble config
• Browse/edit config/warble.rb
• $ warble war # builds WAR
• $ cp app.war [tomcat-home]/webapps
Target audience(s!): Ruby developers new to the JVM; Java developers new to the Ruby Language\nRuby folks, the material in the first few labs may be quite familiar, but we’ll likely be moving quickly.\nJava folks, we’re going to gloss over language features\n
You can’t really talk about what JRuby is without first defining Ruby\nThis is not a primer on Ruby as a language. More a whirlwind tour of the JRuby ecosystem.\n
JRuby is ruby syntax and semantics through and through. Deviations are bugs.\nJVM as a platform has different sweetspots than the MRI VM as a platform\nFor a given set of tasks (CPU-bound performance, high concurrency needs, esoteric platforms) JRuby is a better\n
JRuby is ruby syntax and semantics through and through. Deviations are bugs.\nJVM as a platform has different sweetspots than the MRI VM as a platform\nFor a given set of tasks (CPU-bound performance, high concurrency needs, esoteric platforms) JRuby is a better\n
JRuby is ruby syntax and semantics through and through. Deviations are bugs.\nJVM as a platform has different sweetspots than the MRI VM as a platform\nFor a given set of tasks (CPU-bound performance, high concurrency needs, esoteric platforms) JRuby is a better\n
\n
\n
\n
\n
\n
\n
\n
View the source, run the tests, perhaps play with the code.\n\nOnce everyone’s comfortable running the tests, it’s time to move on.\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
SCOPING dependencies to platform\n
\n
\n
\n
\n
Tuesday at 2:00, Joe Kutner will be talking further about deployment\n