in action!gotocon.com/dl/jaoo-aarhus-2008/slides/olabini_jrubyinaction.pdf · deployment...

241
Ola Bini JRuby Core Developer ThoughtWorks Studios [email protected] http://olabini.com/blog In action! JRuby

Upload: others

Post on 30-Mar-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Ola BiniJRuby Core DeveloperThoughtWorks Studios

[email protected]://olabini.com/blog

In action!JRuby

Page 2: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Agendawhat

why

how

rails

other things

real world

the future

q & a

Page 3: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

what

Page 4: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

What is JRuby

Page 5: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

What is JRubyImplementation of the Ruby language

Page 6: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

What is JRubyImplementation of the Ruby language

Java 1.5+

Page 7: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

What is JRubyImplementation of the Ruby language

Java 1.5+

Open Source

Page 8: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

What is JRubyImplementation of the Ruby language

Java 1.5+

Open Source

Compatible with Ruby 1.8.6 p114

Page 9: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

What is JRubyImplementation of the Ruby language

Java 1.5+

Open Source

Compatible with Ruby 1.8.6 p114

Current versions 1.1.4 and 1.0.3

Page 10: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community

Page 11: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

Page 12: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

40-50 contributors

Page 13: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

40-50 contributors

New projects from JRuby:

Page 14: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

40-50 contributors

New projects from JRuby:

JOni

Page 15: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

40-50 contributors

New projects from JRuby:

JOni

RbYAML, JvYAML, JvYAMLb

Page 16: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

40-50 contributors

New projects from JRuby:

JOni

RbYAML, JvYAML, JvYAMLb

JNA-Posix

Page 17: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Community7.5 core developers

40-50 contributors

New projects from JRuby:

JOni

RbYAML, JvYAML, JvYAMLb

JNA-Posix

JOpenSSL

Page 18: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Compatibility

Page 19: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Page 20: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Page 21: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Page 22: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

Page 23: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

~ 42,000 expectations/assertions

Page 24: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

~ 42,000 expectations/assertions

Prevents regressions

Page 25: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

~ 42,000 expectations/assertions

Prevents regressions

Better definition of Ruby

Page 26: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

~ 42,000 expectations/assertions

Prevents regressions

Better definition of Ruby

Might also prevent community fragmentation

Page 27: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

~ 42,000 expectations/assertions

Prevents regressions

Better definition of Ruby

Might also prevent community fragmentation

Like Sapphire

Page 28: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

CompatibilityUsing the RubySpecs

Applications are king

Rails, RubyGems, Rake, RSpec

Testing is cool

~ 42,000 expectations/assertions

Prevents regressions

Better definition of Ruby

Might also prevent community fragmentation

Like Sapphire

Page 29: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why? why

Page 30: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?

Page 31: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Page 32: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Page 33: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Performance

Page 34: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Performance

Memory

Page 35: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Performance

Memory

C Extensions

Page 36: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Performance

Memory

C Extensions

Libraries

Page 37: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Performance

Memory

C Extensions

Libraries

Politics

Page 38: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby?Threading

Unicode

Performance

Memory

C Extensions

Libraries

Politics

Legacy systems

Page 39: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?

Page 40: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?Same same

Page 41: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?Same same

Conservative organizations (IS)

Page 42: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?Same same

Conservative organizations (IS)

Deployment

Page 43: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?Same same

Conservative organizations (IS)

Deployment

Integration

Page 44: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?Same same

Conservative organizations (IS)

Deployment

Integration

Monitoring

Page 45: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Why JRuby on Rails?Same same

Conservative organizations (IS)

Deployment

Integration

Monitoring

Ruby + Java == Cost efficiency && plausible fallback

Page 46: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

How?how

Page 47: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting started

Page 48: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Page 49: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

Page 50: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Page 51: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Unpack

Page 52: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Unpack

Multiple copies are fine

Page 53: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Unpack

Multiple copies are fine

Add <jruby-dir>/bin to PATH

Page 54: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Unpack

Multiple copies are fine

Add <jruby-dir>/bin to PATH

Install gems

Page 55: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Unpack

Multiple copies are fine

Add <jruby-dir>/bin to PATH

Install gems

gem install rspec

Page 56: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting startedInstall Java

Download http://dist.codehaus.org/jruby/jruby-bin-1.1.4.tar.gz

This includes JRuby, Ruby stdlib, RubyGems and rake

Unpack

Multiple copies are fine

Add <jruby-dir>/bin to PATH

Install gems

gem install rspec

jruby -S gem install rspec

Page 57: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Calling Ruby from Java

// One-time load Ruby runtimeScriptEngineManager factory = new ScriptEngineManager();

ScriptEngine engine = factory.getEngineByName("jruby");

// Evaluate JRuby code from string.try { engine.eval("puts('Hello')");} catch (ScriptException exception) { exception.printStackTrace();}

Page 58: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java Integration

Page 59: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Page 60: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Call methods, construct instances, pass objects around

Page 61: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Call methods, construct instances, pass objects around

camelCase or snake_case both valid

Page 62: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Call methods, construct instances, pass objects around

camelCase or snake_case both valid

Interfaces can be implemented

Page 63: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Call methods, construct instances, pass objects around

camelCase or snake_case both valid

Interfaces can be implemented

Classes can be inherited from

Page 64: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Call methods, construct instances, pass objects around

camelCase or snake_case both valid

Interfaces can be implemented

Classes can be inherited from

Implicit closure conversion

Page 65: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java IntegrationJava types == Ruby types

Call methods, construct instances, pass objects around

camelCase or snake_case both valid

Interfaces can be implemented

Classes can be inherited from

Implicit closure conversion

Extra added features to Rubyfy Java classes and Interfaces

Page 66: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DemoJava Integration

Page 67: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRI

Page 68: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

Page 69: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

will you miss them?

Page 70: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

will you miss them?

No native extensions

Page 71: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

will you miss them?

No native extensions

you might miss them

Page 72: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

will you miss them?

No native extensions

you might miss them

No crappy GC

Page 73: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

will you miss them?

No native extensions

you might miss them

No crappy GC

you won’t miss that

Page 74: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Differences to MRINo continuations

will you miss them?

No native extensions

you might miss them

No crappy GC

you won’t miss that

File and POSIX operations is still not 100%

Page 75: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Rails?

rails

Page 76: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Getting started

[jaoo] (1) ʎ jruby -S gem install rails

[jaoo] (2) ʎ jruby -S gem install activerecord-jdbcmysql-adapter

[jaoo] (3) ʎ jruby -S rails yourapp -d mysql

[jaoo] (4) ʎ cd yourapp

[jaoo] (5) ʎ sed -i -e 's/mysql/jdbcmysql/g' config/database.yml

[jaoo] (6) ʎ jruby script/server

Page 77: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFish

Page 78: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Page 79: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Page 80: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Monitoring etc

Page 81: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Monitoring etc

Support for several alt JVM languages

Page 82: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Monitoring etc

Support for several alt JVM languages

Ruby, PHP, JavaScript

Page 83: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Monitoring etc

Support for several alt JVM languages

Ruby, PHP, JavaScript

[jaoo] (7) ʎ jruby -S gem install glassfish

Page 84: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Monitoring etc

Support for several alt JVM languages

Ruby, PHP, JavaScript

[jaoo] (7) ʎ jruby -S gem install glassfish

Page 85: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

GlassFishModular application server

Full support for JEE 5

Monitoring etc

Support for several alt JVM languages

Ruby, PHP, JavaScript

[jaoo] (7) ʎ jruby -S gem install glassfish

Size of glassfish-0.2.0-universal-java.gem: 2870784 bytes

Page 86: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DemoGlassFish gem

Page 87: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Jetty-Rails

Page 88: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Jetty-RailsNew project by Fabio Kung

Page 89: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Jetty-RailsNew project by Fabio Kung

Works with Warbler configuration

Page 90: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Jetty-RailsNew project by Fabio Kung

Works with Warbler configuration

Similar to the GlassFish gem, but more light weight

Page 91: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Jetty-RailsNew project by Fabio Kung

Works with Warbler configuration

Similar to the GlassFish gem, but more light weight

For development phase of Warbler enabled project

Page 92: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDI

Page 93: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Page 94: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Page 95: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:

Page 96: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:jndi: jdbc/yourapp_production

To your database.yml

Page 97: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:jndi: jdbc/yourapp_production

To your database.yml

Get:

Page 98: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:jndi: jdbc/yourapp_production

To your database.yml

Get:

Manageability

Page 99: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:jndi: jdbc/yourapp_production

To your database.yml

Get:

Manageability

Securability

Page 100: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:jndi: jdbc/yourapp_production

To your database.yml

Get:

Manageability

Securability

Poolability

Page 101: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JNDIIn production

Fall back on regular database configuration

Add:jndi: jdbc/yourapp_production

To your database.yml

Get:

Manageability

Securability

Poolability

Page 102: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment

Page 103: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Page 104: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

Page 105: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Page 106: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Deployed with Capistrano

Page 107: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Deployed with Capistrano

Something in front, like Nginx or Apache HTTPd

Page 108: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Deployed with Capistrano

Something in front, like Nginx or Apache HTTPd

Needs monitoring

Page 109: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Deployed with Capistrano

Something in front, like Nginx or Apache HTTPd

Needs monitoring

Monit

Page 110: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Deployed with Capistrano

Something in front, like Nginx or Apache HTTPd

Needs monitoring

Monit

God

Page 111: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DeploymentTraditional approach

Pack of Mongrels

N mongrels for N concurrent requests

Deployed with Capistrano

Something in front, like Nginx or Apache HTTPd

Needs monitoring

Monit

God

Repeat for each application

Page 112: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: Mongrel

Page 113: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: MongrelSame approach “works”

Page 114: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: MongrelSame approach “works”

For some definition of works

Page 115: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: MongrelSame approach “works”

For some definition of works

Do you want N JVMs?

Page 116: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: Warbler

Page 117: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

Page 118: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

JRuby included

Page 119: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

JRuby included

And so is a Rails servlet

Page 120: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

JRuby included

And so is a Rails servlet

Automates the War configuration

Page 121: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

JRuby included

And so is a Rails servlet

Automates the War configuration

[jaoo] (8) ʎ jruby -S gem install warbler

[jaoo] (9) ʎ jruby -S warble pluginize

Page 122: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

JRuby included

And so is a Rails servlet

Automates the War configuration

[jaoo] (8) ʎ jruby -S gem install warbler

[jaoo] (9) ʎ jruby -S warble pluginize

[jaoo] (10) ʎ jruby -S rake war

Page 123: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Deployment: WarblerInstalls as a gem

JRuby included

And so is a Rails servlet

Automates the War configuration

[jaoo] (8) ʎ jruby -S gem install warbler

[jaoo] (9) ʎ jruby -S warble pluginize

[jaoo] (10) ʎ jruby -S rake war

Page 124: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Other things

smörgåsbord

Page 125: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Ribs

Page 126: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Page 127: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Uses real Hibernate under the covers

Page 128: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Uses real Hibernate under the covers

AR like interface (not compatible, just inspired by AR)

Page 129: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Uses real Hibernate under the covers

AR like interface (not compatible, just inspired by AR)

Can use existing Hibernate mappings and Java domains

Page 130: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Uses real Hibernate under the covers

AR like interface (not compatible, just inspired by AR)

Can use existing Hibernate mappings and Java domains

Alternative to ActiveRecord

Page 131: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Uses real Hibernate under the covers

AR like interface (not compatible, just inspired by AR)

Can use existing Hibernate mappings and Java domains

Alternative to ActiveRecord

Version 0.0.2 out now

Page 132: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RibsNot finished yet

Uses real Hibernate under the covers

AR like interface (not compatible, just inspired by AR)

Can use existing Hibernate mappings and Java domains

Alternative to ActiveRecord

Version 0.0.2 out now

RepositoryUnit of WorkIdentity MapActive RecordData Mapper

Page 133: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

# define a model (not needed at all when following conventions)class Project Ribs! :table => "PROJECTS" do |r| r.id :primary_key, :column => :PROJECT_ID endend

# createproject = R(Project).create(:name => "JRuby", :complexity => 10)project_id = project.id

# queryall_projects = R(Project).alljruby_project = R(Project).get(project_id)

# updatejruby_project.complexity = 37R(jruby_project).save

# destroyR(jruby_project).destroy!

Page 134: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Merb

Page 135: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

MerbJRuby runs Merb

Page 136: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

MerbJRuby runs Merb

JRuby-rack is the preferred solution

Page 137: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

MerbJRuby runs Merb

JRuby-rack is the preferred solution

Should Just Work (TM)

Page 138: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBC

Page 139: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

Page 140: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

There is a DBI driver

Page 141: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

There is a DBI driver

DataMapper driver on the way

Page 142: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

There is a DBI driver

DataMapper driver on the way

And of course, AR-JDBC

Page 143: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

There is a DBI driver

DataMapper driver on the way

And of course, AR-JDBC

JNDI

Page 144: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

There is a DBI driver

DataMapper driver on the way

And of course, AR-JDBC

JNDI

Connection pools

Page 145: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JDBCCan be used directly from JRuby

There is a DBI driver

DataMapper driver on the way

And of course, AR-JDBC

JNDI

Connection pools

Prepared statements

Page 146: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Ever installed RMagick?

Page 147: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java2D

Page 148: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java2DJava2D is available everywhere. And works the same.

Page 149: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java2DJava2D is available everywhere. And works the same.

ImageVoodoo

Page 150: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java2DJava2D is available everywhere. And works the same.

ImageVoodoo

Compatible with ImageScience

Page 151: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Java2DJava2D is available everywhere. And works the same.

ImageVoodoo

Compatible with ImageScience

Works with attachment_fu and others

Page 152: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JRuby internalsJRuby::ast_for("1+1") #=> Java AST

JRuby::ast_for { 1+1 } #=> Java AST

JRuby::compile("1+1") #=> CompiledScript

CompiledScript.inspect_bytecode

JRuby::runtime

JRuby::reference("str")

Page 153: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

... evil stuff

a = "foobar"a.freezeJRuby::reference(a).set_frozen(false)

class Foobar; endsomething = Object.newJRuby::reference(something).set_meta_class(Foobar)

class Foobar; endJRuby::reference(Foobar).get_methods

Page 154: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestR

Page 155: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Page 156: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

Page 157: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Page 158: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Test::Unit

Page 159: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Test::Unit

dust

Page 160: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Test::Unit

dust

Mocha

Page 161: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Test::Unit

dust

Mocha

Expectations

Page 162: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Test::Unit

dust

Mocha

Expectations

Ant, JUnit and Maven 2 integration

Page 163: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JtestRTest Java code with Ruby

Includes

RSpec (and story support)

Test::Unit

dust

Mocha

Expectations

Ant, JUnit and Maven 2 integration

0.3.1 is current version

Page 164: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

DemoTesting with JtestR

Page 165: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Rubiq

Page 166: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Page 167: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Transforms to JRuby AST

Page 168: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Transforms to JRuby AST

... and lets JRuby execute it

Page 169: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Transforms to JRuby AST

... and lets JRuby execute it

Macros

Page 170: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Transforms to JRuby AST

... and lets JRuby execute it

Macros

Read macros (used to implement regexp syntax, for example)

Page 171: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Transforms to JRuby AST

... and lets JRuby execute it

Macros

Read macros (used to implement regexp syntax, for example)

Pure lexical scoping

Page 172: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RubiqLisp layer on top of JRuby

Transforms to JRuby AST

... and lets JRuby execute it

Macros

Read macros (used to implement regexp syntax, for example)

Pure lexical scoping

Lambdas transparently transforms to blocks or Proc.new

Page 173: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Ruvlets

Page 174: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Page 175: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

Page 176: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Page 177: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Expose highly tuned web-infrastructure to Ruby

Page 178: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Expose highly tuned web-infrastructure to Ruby

Similar in L&F to Camping

Page 179: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Expose highly tuned web-infrastructure to Ruby

Similar in L&F to Camping

How it works:

Page 180: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Expose highly tuned web-infrastructure to Ruby

Similar in L&F to Camping

How it works:

Evaluates file from load path based on URL

Page 181: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Expose highly tuned web-infrastructure to Ruby

Similar in L&F to Camping

How it works:

Evaluates file from load path based on URL

File returns an object with a 'service' method defined

Page 182: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

RuvletsExpose Servlets as Ruby API

Because we can!

People keep asking for this....really!

Expose highly tuned web-infrastructure to Ruby

Similar in L&F to Camping

How it works:

Evaluates file from load path based on URL

File returns an object with a 'service' method defined

Object cached for all future requests

Page 183: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Bare bones Ruvlet

class HelloWorld def service(context, request, response) response.content_type = "text/html" response.writer << <<-EOF <html> <head><title>Hello World!</title></head> <body>Hello World!</body> </html> EOF endend

HelloWorld.new

Page 184: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing

Page 185: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

SwingSwing API == large and complex

Page 186: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

SwingSwing API == large and complex

Ruby magic simplifies most of the tricky bits

Page 187: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

SwingSwing API == large and complex

Ruby magic simplifies most of the tricky bits

Java is a very verbose language

Page 188: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

SwingSwing API == large and complex

Ruby magic simplifies most of the tricky bits

Java is a very verbose language

Ruby makes Swing fun (more fun at least)

Page 189: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

SwingSwing API == large and complex

Ruby magic simplifies most of the tricky bits

Java is a very verbose language

Ruby makes Swing fun (more fun at least)

No consistent cross-platform GUI library for Ruby

Page 190: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

SwingSwing API == large and complex

Ruby magic simplifies most of the tricky bits

Java is a very verbose language

Ruby makes Swing fun (more fun at least)

No consistent cross-platform GUI library for Ruby

Swing works everywhere Java does

Page 191: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - the direct approachimport javax.swing.JFrameimport javax.swing.JButton

frame = JFrame.new("Swing is easy now!")frame.set_size 300, 300frame.always_on_top = true

button = JButton.new("Press me!")button.add_action_listener do |evt| evt.source.text = "Don't press me again!" evt.source.enabled = falseend

frame.add(button)frame.show

Page 192: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - Cheri (builder)include Cheri::Swing

frame = swing.frame("Swing builders!") { |form| size 300, 300 box_layout form, :Y_AXIS content_pane { background :WHITE }

button("Event binding is nice") { |btn| on_click { btn.text = "You clicked me!" } }}

frame.visible = true

Page 193: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - Profligacyclass ProfligacyDemo import javax.swing.* include Profligacy

def initialize layout = "[<translate][*input][>result]" @ui = Swing::LEL.new(JFrame, layout) {|cmps, ints| cmps.translate = JButton.new("Translate") cmps.input = JTextField.new cmps.result = JLabel.new

translator = proc {|id, evt| original = @ui.input.text translation = MyTranslator.translate(original) @ui.result.text = translation }

ints.translate = {:action => translator} } endend

Page 194: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - MonkeyBars (tools)

Page 195: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - MonkeyBars (tools)GUI editor friendly (e.g. NetBeans “Matisse”)

Page 196: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - MonkeyBars (tools)GUI editor friendly (e.g. NetBeans “Matisse”)

Simple Ruby MVC based API

Page 197: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Swing - MonkeyBars (tools)GUI editor friendly (e.g. NetBeans “Matisse”)

Simple Ruby MVC based API

Combines best of both worlds

Page 198: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

real world

Page 199: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Is anyone using it?

Page 200: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Is anyone using it?Mingle (ThoughtWorks)

Page 201: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Is anyone using it?Mingle (ThoughtWorks)

Mix (Oracle)

Page 202: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Is anyone using it?Mingle (ThoughtWorks)

Mix (Oracle)

MediaCast (Sun)

Page 203: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Is anyone using it?Mingle (ThoughtWorks)

Mix (Oracle)

MediaCast (Sun)

Kenai (Sun)

Page 204: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Is anyone using it?Mingle (ThoughtWorks)

Mix (Oracle)

MediaCast (Sun)

Kenai (Sun)

Sonar (Open Source, Hortis)

Page 205: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Monitoring

Page 206: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Performance

Page 207: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

PerformanceHard question of course

Page 208: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

PerformanceHard question of course

Most benchmarks and apps are 2-3x faster than MRI

Page 209: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

PerformanceHard question of course

Most benchmarks and apps are 2-3x faster than MRI

Rails is on par

Page 210: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

PerformanceHard question of course

Most benchmarks and apps are 2-3x faster than MRI

Rails is on par

We are working on this

Page 211: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

0!

15!

30!

45!

60!

75!

5! 10! 15! 20! 25! 30! 35! 40! 45! 50! 55! 60! 65! 70! 75! 80! 85! 90! 95! 100!

avg

rep

ly r

ate!

request rate!

Request Scaling (1 process or runtime)!

webrick (mri)! mongrel (mri)! glassfish (jruby)!

Page 212: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

0!

50!

100!

150!

200!

250!1

5!

30!

45!

60!

75!

90!

10

5!

12

0!

13

5!

15

0!

16

5!

18

0!

19

5!

21

0!

22

5!

24

0!

25

5!

27

0!

28

5!

30

0!

Avg

rep

ly r

ate!

Request rate!

JRuby/Glassfish!

1 runtime (interpolated above 90)! 3 runtimes!

Page 213: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

the future

Page 214: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and Rubinius

Page 215: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

Page 216: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Page 217: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Page 218: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Page 219: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Might give interpreted performance improvement

Page 220: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Might give interpreted performance improvement

Rubinius

Page 221: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Might give interpreted performance improvement

Rubinius

Simple machine

Page 222: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Might give interpreted performance improvement

Rubinius

Simple machine

Quite outdated at the moment

Page 223: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Might give interpreted performance improvement

Rubinius

Simple machine

Quite outdated at the moment

Will be redone after Rubinius C++ engine finished

Page 224: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

YARV and RubiniusYARV

2.0 Compatibility

Simple machine

Simple compiler

Might give interpreted performance improvement

Rubinius

Simple machine

Quite outdated at the moment

Will be redone after Rubinius C++ engine finished

Why do it? Why not?

Page 225: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machine

Page 226: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Page 227: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Page 228: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Page 229: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Faster reflection, escape analysis

Page 230: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Faster reflection, escape analysis

Interface injection

Page 231: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Faster reflection, escape analysis

Interface injection

Continuations

Page 232: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Faster reflection, escape analysis

Interface injection

Continuations

Value objects (Lisp fixnums)

Page 233: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Faster reflection, escape analysis

Interface injection

Continuations

Value objects (Lisp fixnums)

Tuple types

Page 234: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JSR292 and the DaVinci machineDynamic invocation: non-java call sites

Method handles

Anonymous classes

Faster reflection, escape analysis

Interface injection

Continuations

Value objects (Lisp fixnums)

Tuple types

Tail calls

Page 235: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JRuby future

Page 236: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JRuby futureInterpreter

Page 237: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JRuby futureInterpreter

Java Integration

Page 238: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JRuby futureInterpreter

Java Integration

Ahead-of-time compilation

Page 239: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

JRuby futureInterpreter

Java Integration

Ahead-of-time compilation

More library integration

Page 240: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano
Page 241: In action!gotocon.com/dl/jaoo-aarhus-2008/slides/OlaBini_JRubyInAction.pdf · Deployment Traditional approach Pack of Mongrels N mongrels for N concurrent requests Deployed with Capistrano

Q&AAQ and