SlideShare ist ein Scribd-Unternehmen logo
1 von 89
JRuby Jam
Charles Nutter & Nick Sieger


@headius   @nicksieger
JRuby Overview
 JRuby > Ruby + Java
What's Different? 
The Bad
Memory Footprint
Memory Footprint
  Base memory size is larger
(Footprint over time is smaller)
Memory Footprint
        Objects are larger
(But instance var table is smaller)
Missing or Disabled
     Features
Missing or Disabled
     Features
     No Kernel#fork
Missing or Disabled
     Features
   No continuations (callcc)
  (except for speciïŹc forms)
Missing or Disabled
     Features
  ObjectSpace off by default
      (-X+O to enable)
Missing or Disabled
     Features
 set_trace_func off by default
     (--debug to enable)
C Extensions
     Shipped in JRuby 1.6,
still considered experimental
The Good
     
Getting Started
     Install a JVM
 (depends on your OS)
Getting Started
   rvm install jruby
Getting Started
Download from jruby.org
Ruby Itself
      
Ruby Itself
Ruby 1.8.7 and 1.9.2 in the box
Ruby Itself
    Multi-VM support
(many apps in one process)
Ruby Itself
Solid across platforms
Ruby Itself
  Solid across platforms
(Best Ruby on Windows?)
Ruby Itself
  Solid across platforms
(Best Ruby on OpenVMS?)
Ruby Itself
 Solid across platforms
(Best Ruby on zLinux?)
Java Virtual Machine
       (JVM)
           
Java Virtual Machine
       (JVM)
     Java libraries like Swing
 (or Scala, Groovy, Clojure, etc)
# Import Java packages
require 'java'

# Pull in some classes
java_import javax.swing.JFrame
java_import javax.swing.JButton

# create frame and button
frame = JFrame.new("Hello Swing")
button = JButton.new("Klick Me!")
button.add_action_listener do
  button.text = "You klicked!"
end

# Add the button to the frame
frame.content_pane.add(button)

# Show frame
frame.default_close_operation =
JFrame::EXIT_ON_CLOSE
frame.pack
frame.visible = true
Java Virtual Machine
       (JVM)
    Tools like VisualVM
Java Virtual Machine
       (JVM)
    Concurrent threading
Java Virtual Machine
       (JVM)
   Best garbage collectors
Java Virtual Machine
       (JVM)
   Optimizing JIT compiler
Java Virtual Machine
       (JVM)
 New dynamic dispatch support
       (invokedynamic)
Invokedynamic
What Java 7 Means for JRuby 1.7
Ruby = Method Calls
 Lots and lots and lots and lots...
def foo
  bar
end

def bar
  baz     foo   bar   baz
end

def baz
  # ...
end
def foo
                    JRuby on Java 5/6
  bar
end

def bar          JRuby             JRuby
  baz     foo      call    bar       call      baz
end               logic             logic
def baz
  # ...
end
                Kills many JVM optimizations
def foo
                       JRuby on Java 7
  bar




                  X X
end

def bar            JRuby              JRuby
  baz     foo        call    bar        call   baz
end                 logic              logic
def baz
  # ...
end
                Dynamic call logic built into JVM
def foo
                     JRuby on Java 7
  bar
end

def bar
  baz     foo               bar                  baz
end

def baz
  # ...
end
                Straight through dispatch path
def foo
                     JRuby on Java 7
  bar
end

def bar
  baz          foo        bar       baz
end

def baz
  # ...
end
          Optimizations (like inlining) can happen!
Benchmarks!
You know you love them.
A “Better” ïŹb bench
  bench_ïŹb_complex.rb 5 35
“Richards”
bench_richards.rb 1000000
Red/Black Tree
github.com/headius/redblack
Wait for it...
    Benchmarks are benchmarks.
If you don’t like them, give us yours!
Deployment
Ruby servers   WAR ïŹles            Cloud

  WEBrick       GlassFish     EY AppCloud

  Trinidad       Tomcat        AppEngine

 TorqueBox       JBoss             AWS EB




         http://ey.io/webservers
torquebox.org/




$ torquebox deploy ~/src/sinatra/basic
$ torquebox run
Warbler
      Rails in a .war ïŹle

 INSTALL   gem install warbler




github.com/jruby/warbler
$ cd ~/apps/recordstore
$ cd ~/apps/recordstore

$ warble executable war
rm -f recordstore.war
Creating recordstore.war
$ cd ~/apps/recordstore

$ warble executable war
rm -f recordstore.war
Creating recordstore.war

$ java -jar recordstore.war
<server starts on port 8080>
JRuby-Rack
Servlet => Rack conversion layer
 Used by Warbler and Trinidad

 github.com/jruby/jruby-rack
JRuby-Rack


            JRuby-Rack             Your
 Servlet
              servlet    Rack   Rails/Rack
container      ïŹlter               app
JRuby on AppCloud
    EYSD, JRuby 1.6.x, Trinidad
docs.engineyard.com/appcloud-tech-stack.html
JRuby on AppCloud
                           Dashboard deploy
Add to GemïŹle
gem 'trinidad'




Command-line deploy
$ gem install engineyard
$ cd ~/apps/recordstore
$ ey deploy
Tuning
Your application is special
JVM server compiler
   Always run with --server
conïŹg.threadsafe!
         1 runtime > pooled runtimes


      Trinidad                       Warbler
trinidad --threadsafe   config.webxml.jruby.max.runtimes = 1
Database pool
            default is 5
threadsafe needs more connections
           database.yml
           production:
             adapter: mysql
             pool: 200
HTTP connection thread pool

# of open ïŹles limit

JVM max heap size (-Xmx___m)

JVM GC -XX:+UseConcMarkSweepGC   -XX:+UseG1GC
Performance
JRuby vs. Passenger
Static Benchmark

     EY AppCloud          c1.medium

       github.com/
    nicksieger/redmine
                            MySQL

     Passenger 3          JRuby 1.6.4
     REE 2011.03         Trinidad 1.2.1
Request/reply scaling curve
                      90

                      80
                                     jruby reply rate
                      70             passenger reply rate
Requests per second




                      60

                      50

                      40

                      30

                      20

                      10

                       0
                           10   20      30      40    50    60    70   80   90
                                             Replies per second
Request/reply scaling curve
                      90

                      80
                                     jruby reply rate
                      70             passenger reply rate
Requests per second




                                                                          PS
                      60

                      50                                               OO        did I mention
                      40                                                          JRuby’s in
                      30                                                             beta?
                      20

                      10

                       0
                           10   20      30      40    50    60    70   80   90
                                             Replies per second
Passenger
JRuby
Catastrophic failure


       Previous page
     (no longer visible)
Passenger Memory
JRuby Memory
Performance
 Takeaways
Speed-competitive
       Will require warm-up
Faster with newer versions of Java
Memory efïŹcient
     at higher throughput
Threads lighter than processes
May need tuning
   Guidelines and JVM tools
will help pinpoint conïŹguration
JRuby T-Shirts!
Try JRuby on Engine Yard Cloud Today

 500 compute hours for free

 Full-featured production ready
 environment

 Start and stop your
 environment as needed

 No credit card required and
 completely risk free
Engine Yard @ JavaOne!
 Stop by our exhibition
 booth

 JRuby team ofïŹce hours

 Talks by JRuby team

 Talk by Mike Piech and
 Jacob Lehrbaum on the
 value of PaaS
Q&A
We must have missed something

Weitere Àhnliche Inhalte

Ähnlich wie JRuby Jam Session

When Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the EnterpriseWhen Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the Enterprise
benbrowning
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
tobiascrawley
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
tobiascrawley
 
Efficient use of NodeJS
Efficient use of NodeJSEfficient use of NodeJS
Efficient use of NodeJS
Yura Bogdanov
 
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
Darshan Karandikar
 

Ähnlich wie JRuby Jam Session (20)

When Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the EnterpriseWhen Two Worlds Collide: Java and Ruby in the Enterprise
When Two Worlds Collide: Java and Ruby in the Enterprise
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVM
 
Kumar sv07
Kumar sv07Kumar sv07
Kumar sv07
 
Euruko 2012 - JRuby
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRuby
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
JUDCon 2010 Boston : TorqueBox
JUDCon 2010 Boston : TorqueBoxJUDCon 2010 Boston : TorqueBox
JUDCon 2010 Boston : TorqueBox
 
Rubinius 1.0 and more!
Rubinius 1.0 and more!Rubinius 1.0 and more!
Rubinius 1.0 and more!
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Efficient use of NodeJS
Efficient use of NodeJSEfficient use of NodeJS
Efficient use of NodeJS
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
RJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityRJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperability
 
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Load testing with Blitz
Load testing with BlitzLoad testing with Blitz
Load testing with Blitz
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 
XRuby_Overview_20070831
XRuby_Overview_20070831XRuby_Overview_20070831
XRuby_Overview_20070831
 

Mehr von Engine Yard

Engine Yard Partner Program 2014
Engine Yard Partner Program 2014Engine Yard Partner Program 2014
Engine Yard Partner Program 2014
Engine Yard
 
Rubinius and Ruby | A Love Story
Rubinius and Ruby | A Love Story Rubinius and Ruby | A Love Story
Rubinius and Ruby | A Love Story
Engine Yard
 
Everything Rubinius
Everything RubiniusEverything Rubinius
Everything Rubinius
Engine Yard
 

Mehr von Engine Yard (19)

Engine Yard Partner Program 2014
Engine Yard Partner Program 2014Engine Yard Partner Program 2014
Engine Yard Partner Program 2014
 
Getting Started with PHP on Engine Yard Cloud
Getting Started with PHP on Engine Yard CloudGetting Started with PHP on Engine Yard Cloud
Getting Started with PHP on Engine Yard Cloud
 
Engine Yard Cloud Architecture Enhancements
Engine Yard Cloud Architecture EnhancementsEngine Yard Cloud Architecture Enhancements
Engine Yard Cloud Architecture Enhancements
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Simplifying PCI on a PaaS Environment
Simplifying PCI on a PaaS EnvironmentSimplifying PCI on a PaaS Environment
Simplifying PCI on a PaaS Environment
 
The Tao of Documentation
The Tao of DocumentationThe Tao of Documentation
The Tao of Documentation
 
Innovate Faster in the Cloud with a Platform as a Service
Innovate Faster in the Cloud with a Platform as a ServiceInnovate Faster in the Cloud with a Platform as a Service
Innovate Faster in the Cloud with a Platform as a Service
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
JRuby: Enhancing Java Developers Lives
JRuby: Enhancing Java Developers LivesJRuby: Enhancing Java Developers Lives
JRuby: Enhancing Java Developers Lives
 
High Performance Ruby: Evented vs. Threaded
High Performance Ruby: Evented vs. ThreadedHigh Performance Ruby: Evented vs. Threaded
High Performance Ruby: Evented vs. Threaded
 
Release Early & Release Often: Reducing Deployment Friction
Release Early & Release Often: Reducing Deployment FrictionRelease Early & Release Often: Reducing Deployment Friction
Release Early & Release Often: Reducing Deployment Friction
 
Rubinius and Ruby | A Love Story
Rubinius and Ruby | A Love Story Rubinius and Ruby | A Love Story
Rubinius and Ruby | A Love Story
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
 
JRuby: Apples and Oranges
JRuby: Apples and OrangesJRuby: Apples and Oranges
JRuby: Apples and Oranges
 
Developing a Language
Developing a LanguageDeveloping a Language
Developing a Language
 
Debugging Ruby Systems
Debugging Ruby SystemsDebugging Ruby Systems
Debugging Ruby Systems
 
Geemus
GeemusGeemus
Geemus
 
Everything Rubinius
Everything RubiniusEverything Rubinius
Everything Rubinius
 
Rails Hosting and the Woes
Rails Hosting and the WoesRails Hosting and the Woes
Rails Hosting and the Woes
 

KĂŒrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

KĂŒrzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

JRuby Jam Session