SlideShare a Scribd company logo
1 of 28
Download to read offline
JRoR
                                  Deploying Rails on JRuby
                                    Per Olesen <polesen@nordija.com>




Nordija A/S Nørgaardsvej 7 DK-2800 Kgs. Lyngby www.nordija.com +45 70 20 25 10
Agenda

• JRuby

• Rails Integration

• Future Perspectives
JRuby
Why JRuby?

• Dynamic Languages are hot and cool :-)

• To leverage the lovely Ruby language on the JVM

• To make all the nice, proven libraries of the Java platform
  available to Ruby code

• The best of both worlds?

• To ease the transition from Java into dynamic languages

• To fight M$ and the DLR?
JRuby: The Project

• Ruby on the Java VM

• Partly sponsored by Sun
   – Charles Oliver Nutter (Sun employee now)
   – Thomas Enebo (Sun employee now)
   – Ola Bini (ThoughtWorker)
   – Nick Sieger (Digital River, Inc)




• Goal
   – Provide a platform to execute Ruby code on the JVM
JRuby: The Platform

            Ruby source                      Ruby std. Libs (in ruby)




Ruby native code
                                                                JIT compiled
 libs rewritten in                             JIT                rubycode
        Java              Interpreter        Compiler            (bytecode)
    (bytecode)

                                 JRuby Runtime


                                   The JVM
Example: The IRB Console

• Download the zip and unzip

• Set JRUBY_HOME=path to unzip place

• Set PATH=%JRUBY_HOME%bin;%PATH%

• Type: jirb <enter>

• Take a tour in the unzipped dirs

• Live example.....
Java Integration: (J)Ruby into Java

• With JSE6, you can use JSR-223 APIs
  – Needs: https://scripting.dev.java.net/

• Or else, there is BSF integration

• Or, simply code it
   – Ruby runtime = Ruby.getDefaultInstance()
   – runtime.evalScript(”...”)

• Live example....
Java Integration: Java into (J)Ruby

• Low-level API
   – Wrapping in JavaObject, JavaMethod, JavaField
   – java_method.invoke(java_object, java_field, ...)

• High-level API
   – Wrapping low-level API in a JavaProxy
   – A JavaProxy has all the methods of the Java object
     wrapped
   – Calls the actual Java object methods using low-level
     API
   – Output from a proxy is automatically wrapped

• Live example....
Performance Tips

• Turn on -server VM (JVM setting)

• Turn on JIT (JRuby setting)

• Turning off ObjectSpace
   – Breaks ability to look into the heap from app. code

• Turn on thread-pooling
   – Ruby uses green-threads (yuk!)
   – Some Ruby libs spawns a lot of threads
   – Expensive with native threads
Rails Integration
Why Rails Integration?

• Rails deployment can be complex
   – Rails is not thread-safe
   – Multi-process deployment
   – Needs load-balancing front-end
   – Harder to monitor
   – Not everything in one deployment unit

• Rails deployment for a Java-shop
   – A completely new platform to learn
   – Not what Joe-systems-management likes
   – Existing (Java appserver) setup not leveraged
Parts of Rails Integration

• ActiveRecord-JDBC
   – Actually separate, but important part of rails

• RailsIntegration
   – A plugin for rails to do war building
   – Some session handling code
   – A dispatcher servlet into JRuby runtime
Installing Rails Integration

• First, you need a rails project
   – Gem install rails -y
   – Rails helloworld

• Then, install rails plugin


script/plugin install
   svn://rubyforge.org/var/svn/jruby-extras/trunk/railsintegration/plugins/goldspike
Installing ActiveRecord-JDBC

• Gem install activerecord-jdbc -y

• configenvironment.rb
   – After the ”require File.join(...'boot')” line, add this:


if RUBY_PLATFORM =~ /java/
    require 'rubygems'
    require 'active_record'
    require 'active_record/connection_adapters/jdbc_adapter'
    RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end
Using Rails Integration

• See the new tasks with: ”rake --tasks”

• Using war packaging
   – Rake war:standalone:create
   – Rake war:standalone:run
Using ActiveRecord-JDBC

• Generate model and controller
   – scriptgenerate model post ...
   – scriptgenerate controller Post
   – Add ”scaffold :post”

• Edit configdatabase.yml
   – Adapter: mysql
   – Url: jdbc:mysql://...

• Migrate

• Add jdbc driver jar dependency in ”configwar.rb”:
   – maven_library 'mysql', 'mysql-connector-java', '3.1.12'
Deployment in a war

• Why?
  – One deployment unit
  – Leverage JEE appservers multi-threading

• RailsServlet
   – Instantiates a pool of Ruby runtimes
   – Pooling overcomes threading issues
   – Rails is initialized in each runtime
   – Dispatches incoming requests into rails
Future Perspectives
Why is this hard? (part 1)

• No RubySpec (yet)
   – There is a wiki working on this

• Large parts of the Ruby platform is in native code
   – Must be rewritten in Ruby or Java
   – Rubinius might help out here
   – Lots of 3. part libs will not be rewritten
     (as part of the JRuby project)

• Parts of the Ruby platform are un-doable on JSE platform
   – Green threading
   – File operations
   – Fine grained timing
Why is this hard? (part 2)

• Dynamic languages are different!
   – You can do things that are not possible in statically
     typed languages

• The JVM is not a good fit for dynamic languages (yet)

• JVM fixes for dynamic languages
   – Invokedynamic
   – Code hotswapping
   – JSR-292
Performance on the JVM

• Today
   – Significantly slower on JRuby
   – But, not many optimizations done (yet)
   – Faster on some places where hotspot kicks in

• Future
   – Invokedynamic, hotswapping, etc...
   – Might enable better performance
   – The hotspot compiler might kick-ass then

• What is ”performance enough”?
  – How much do you really need if you can scale out?
  – Ease of Development is important
Ruby 1.9

• Current Ruby 1.8 mostly run on MRI

• Ruby 1.9
   – The upcoming implementation to measure against
   – Will be a true bytecode-based VM

• VM bytecode targeted ruby language
   – Will give better ability to tailor performance to the
     language
Other X-platform Ruby Projects

• XRuby
   – Ruby to Java Bytecode Compiler

• Rubinius
   – A Ruby implementation in Ruby
   – Based on Smalltalk-80 (Squeak)
   – Rewriting the complete Ruby standard lib. in Ruby
   – Others can use the rewrite on their implementations

• Ruby on .Net compiler
   – Gardens Point Ruby.NET compiler (MSIL based)
   – M$ IronRuby (DLR based)
M$: Dynamic Language Runtime

• A Dynamic Runtime on top of the CLR

• Type System
   – A unified type-system for dynamic languages and the
     .Net platform
   – Passing objects between IronRuby, IronPython and
     .Net platform

• Part of IronPython sources now (I think)

• SilverLight will utilize this (I think)
Who are doing the JRuby Dance?

• ThoughtWorks
   – Mingle
   – CruiseControl.rb (simply ruby)
   – A lot of Ruby projects

• Others, I guess!?
   – This is new stuff
   – Promising and steaming hot, but new stuff!
Resources

• http://jruby.codehaus.org/
• http://www.headius.com/rubyspec/
• http://rubyforge.org/projects/jruby-extras/

• Me
   – Per Olesen <polesen@nordija.com>
   – http://techpolesen.blogspot.com/
JRoR Deploying Rails on JRuby

More Related Content

What's hot

Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
20140419 oedo rubykaigi04
20140419 oedo rubykaigi0420140419 oedo rubykaigi04
20140419 oedo rubykaigi04Hiroshi SHIBATA
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mrubyHiroshi SHIBATA
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the worldHiroshi SHIBATA
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02Hiroshi SHIBATA
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?Hiroshi SHIBATA
 
20140626 red dotrubyconf2014
20140626 red dotrubyconf201420140626 red dotrubyconf2014
20140626 red dotrubyconf2014Hiroshi SHIBATA
 
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rbHow to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rbHiroshi SHIBATA
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for RubyHiroshi SHIBATA
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesHiroshi SHIBATA
 
Improve extension API: C++ as better language for extension
Improve extension API: C++ as better language for extensionImprove extension API: C++ as better language for extension
Improve extension API: C++ as better language for extensionKouhei Sutou
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage librarymametter
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled BundlerHiroshi SHIBATA
 
Gate of Agile Web Development
Gate of Agile Web DevelopmentGate of Agile Web Development
Gate of Agile Web DevelopmentKoichi ITO
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Hiroshi SHIBATA
 
Leave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraLeave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraHiroshi SHIBATA
 

What's hot (20)

Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
20140419 oedo rubykaigi04
20140419 oedo rubykaigi0420140419 oedo rubykaigi04
20140419 oedo rubykaigi04
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02
 
20140925 rails pacific
20140925 rails pacific20140925 rails pacific
20140925 rails pacific
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
20140626 red dotrubyconf2014
20140626 red dotrubyconf201420140626 red dotrubyconf2014
20140626 red dotrubyconf2014
 
How to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rbHow to develop Jenkins plugin using to ruby and Jenkins.rb
How to develop Jenkins plugin using to ruby and Jenkins.rb
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
 
Improve extension API: C++ as better language for extension
Improve extension API: C++ as better language for extensionImprove extension API: C++ as better language for extension
Improve extension API: C++ as better language for extension
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled Bundler
 
What's new in RubyGems3
What's new in RubyGems3What's new in RubyGems3
What's new in RubyGems3
 
Gate of Agile Web Development
Gate of Agile Web DevelopmentGate of Agile Web Development
Gate of Agile Web Development
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Leave end-to-end testing to Capybara
Leave end-to-end testing to CapybaraLeave end-to-end testing to Capybara
Leave end-to-end testing to Capybara
 

Similar to JRoR Deploying Rails on JRuby

J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The JvmQConLondon2008
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Touroscon2007
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0Jan Sifra
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyAmit Solanki
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of RubyUday Bhaskar
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyajuckel
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
Rails On Spring
Rails On SpringRails On Spring
Rails On Springswamy g
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby.toster
 

Similar to JRoR Deploying Rails on JRuby (20)

J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 
Ugo Cei Presentation
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei Presentation
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Ruby V Ms A Comparison
Ruby V Ms A ComparisonRuby V Ms A Comparison
Ruby V Ms A Comparison
 
JRuby Basics
JRuby BasicsJRuby Basics
JRuby Basics
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of Ruby
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
L R U G - JRuby
L R U G - JRubyL R U G - JRuby
L R U G - JRuby
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Why Java
Why JavaWhy Java
Why Java
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Rails On Spring
Rails On SpringRails On Spring
Rails On Spring
 
Real World Technologies
Real World TechnologiesReal World Technologies
Real World Technologies
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
 

More from elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

More from elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Recently uploaded

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

JRoR Deploying Rails on JRuby

  • 1. JRoR Deploying Rails on JRuby Per Olesen <polesen@nordija.com> Nordija A/S Nørgaardsvej 7 DK-2800 Kgs. Lyngby www.nordija.com +45 70 20 25 10
  • 2. Agenda • JRuby • Rails Integration • Future Perspectives
  • 4. Why JRuby? • Dynamic Languages are hot and cool :-) • To leverage the lovely Ruby language on the JVM • To make all the nice, proven libraries of the Java platform available to Ruby code • The best of both worlds? • To ease the transition from Java into dynamic languages • To fight M$ and the DLR?
  • 5. JRuby: The Project • Ruby on the Java VM • Partly sponsored by Sun – Charles Oliver Nutter (Sun employee now) – Thomas Enebo (Sun employee now) – Ola Bini (ThoughtWorker) – Nick Sieger (Digital River, Inc) • Goal – Provide a platform to execute Ruby code on the JVM
  • 6. JRuby: The Platform Ruby source Ruby std. Libs (in ruby) Ruby native code JIT compiled libs rewritten in JIT rubycode Java Interpreter Compiler (bytecode) (bytecode) JRuby Runtime The JVM
  • 7. Example: The IRB Console • Download the zip and unzip • Set JRUBY_HOME=path to unzip place • Set PATH=%JRUBY_HOME%bin;%PATH% • Type: jirb <enter> • Take a tour in the unzipped dirs • Live example.....
  • 8. Java Integration: (J)Ruby into Java • With JSE6, you can use JSR-223 APIs – Needs: https://scripting.dev.java.net/ • Or else, there is BSF integration • Or, simply code it – Ruby runtime = Ruby.getDefaultInstance() – runtime.evalScript(”...”) • Live example....
  • 9. Java Integration: Java into (J)Ruby • Low-level API – Wrapping in JavaObject, JavaMethod, JavaField – java_method.invoke(java_object, java_field, ...) • High-level API – Wrapping low-level API in a JavaProxy – A JavaProxy has all the methods of the Java object wrapped – Calls the actual Java object methods using low-level API – Output from a proxy is automatically wrapped • Live example....
  • 10. Performance Tips • Turn on -server VM (JVM setting) • Turn on JIT (JRuby setting) • Turning off ObjectSpace – Breaks ability to look into the heap from app. code • Turn on thread-pooling – Ruby uses green-threads (yuk!) – Some Ruby libs spawns a lot of threads – Expensive with native threads
  • 12. Why Rails Integration? • Rails deployment can be complex – Rails is not thread-safe – Multi-process deployment – Needs load-balancing front-end – Harder to monitor – Not everything in one deployment unit • Rails deployment for a Java-shop – A completely new platform to learn – Not what Joe-systems-management likes – Existing (Java appserver) setup not leveraged
  • 13. Parts of Rails Integration • ActiveRecord-JDBC – Actually separate, but important part of rails • RailsIntegration – A plugin for rails to do war building – Some session handling code – A dispatcher servlet into JRuby runtime
  • 14. Installing Rails Integration • First, you need a rails project – Gem install rails -y – Rails helloworld • Then, install rails plugin script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/railsintegration/plugins/goldspike
  • 15. Installing ActiveRecord-JDBC • Gem install activerecord-jdbc -y • configenvironment.rb – After the ”require File.join(...'boot')” line, add this: if RUBY_PLATFORM =~ /java/ require 'rubygems' require 'active_record' require 'active_record/connection_adapters/jdbc_adapter' RAILS_CONNECTION_ADAPTERS = %w(jdbc) end
  • 16. Using Rails Integration • See the new tasks with: ”rake --tasks” • Using war packaging – Rake war:standalone:create – Rake war:standalone:run
  • 17. Using ActiveRecord-JDBC • Generate model and controller – scriptgenerate model post ... – scriptgenerate controller Post – Add ”scaffold :post” • Edit configdatabase.yml – Adapter: mysql – Url: jdbc:mysql://... • Migrate • Add jdbc driver jar dependency in ”configwar.rb”: – maven_library 'mysql', 'mysql-connector-java', '3.1.12'
  • 18. Deployment in a war • Why? – One deployment unit – Leverage JEE appservers multi-threading • RailsServlet – Instantiates a pool of Ruby runtimes – Pooling overcomes threading issues – Rails is initialized in each runtime – Dispatches incoming requests into rails
  • 20. Why is this hard? (part 1) • No RubySpec (yet) – There is a wiki working on this • Large parts of the Ruby platform is in native code – Must be rewritten in Ruby or Java – Rubinius might help out here – Lots of 3. part libs will not be rewritten (as part of the JRuby project) • Parts of the Ruby platform are un-doable on JSE platform – Green threading – File operations – Fine grained timing
  • 21. Why is this hard? (part 2) • Dynamic languages are different! – You can do things that are not possible in statically typed languages • The JVM is not a good fit for dynamic languages (yet) • JVM fixes for dynamic languages – Invokedynamic – Code hotswapping – JSR-292
  • 22. Performance on the JVM • Today – Significantly slower on JRuby – But, not many optimizations done (yet) – Faster on some places where hotspot kicks in • Future – Invokedynamic, hotswapping, etc... – Might enable better performance – The hotspot compiler might kick-ass then • What is ”performance enough”? – How much do you really need if you can scale out? – Ease of Development is important
  • 23. Ruby 1.9 • Current Ruby 1.8 mostly run on MRI • Ruby 1.9 – The upcoming implementation to measure against – Will be a true bytecode-based VM • VM bytecode targeted ruby language – Will give better ability to tailor performance to the language
  • 24. Other X-platform Ruby Projects • XRuby – Ruby to Java Bytecode Compiler • Rubinius – A Ruby implementation in Ruby – Based on Smalltalk-80 (Squeak) – Rewriting the complete Ruby standard lib. in Ruby – Others can use the rewrite on their implementations • Ruby on .Net compiler – Gardens Point Ruby.NET compiler (MSIL based) – M$ IronRuby (DLR based)
  • 25. M$: Dynamic Language Runtime • A Dynamic Runtime on top of the CLR • Type System – A unified type-system for dynamic languages and the .Net platform – Passing objects between IronRuby, IronPython and .Net platform • Part of IronPython sources now (I think) • SilverLight will utilize this (I think)
  • 26. Who are doing the JRuby Dance? • ThoughtWorks – Mingle – CruiseControl.rb (simply ruby) – A lot of Ruby projects • Others, I guess!? – This is new stuff – Promising and steaming hot, but new stuff!
  • 27. Resources • http://jruby.codehaus.org/ • http://www.headius.com/rubyspec/ • http://rubyforge.org/projects/jruby-extras/ • Me – Per Olesen <polesen@nordija.com> – http://techpolesen.blogspot.com/