SlideShare a Scribd company logo
1
Once upon a time…
   powerful Java          on their         beautiful Ruby
                         way to win

 the plot to unfold   Enterprize              battles to be won

    when Java, Ruby tried to win battles on their own…

     there were happy times…   …& some down times…
                           …….
    then comes the time… Java falls in love with Ruby…
           (a little rhyming love song…I promise)
                   now wait for the climax…
No background music      Fast & dramatic      No popcorn break    2
The script writer & confessions…
x I’m neither too deep into Ruby nor have I run too far onto Rails
  so far

But I love its Simplicity

 I think & code in usual Java & JEE

And I love its Class

 I architect & code solutions at TCS

 Thrilled to talk about JRuby when one
  of it’s creators & a JRuby hero is here!
  (Unbelievable!)

x I tried, but couldn’t further shorten title of this story…
                                                                3
The plot
             Micro-blogging @CustCollab

                      API
          Search              Public/private/
                               corporate/auto
           Profiles         follow communities
 Smart
                   Follow, unfollow,
 phones                                     Micro-blogging
                      invites etc.
   Pretty std                                notifications
 deply arch with           Usage
      DMZ                expected to          Timelines,
                        over a period      threads, hashtags
     200,000+
    total users &          Notifications
                         from other apps
                                                               4
The actors supporting Java & Ruby
/*
* @author #jruby.org
*/
public class JRuby implements Ruby {
    /*
    * This implementation of Ruby programming
    * language brings class to Ruby/Rails
    * & simplicity to Java/JEE.
    */
    …
}                                               5
“Ruby on Rails® is an open-source web framework that's
     optimized for programmer's happiness and sustainable
     productivity. It lets you write beautiful code by favoring
     convention over configuration.” - rubyonrails.org




                                                                  6
“On a rail track” by Ahmad Kavousian (flickr)
Is it


                         the
                         Silver
                         Bullet?
                               7
Silver bullet (flickr)
Large Crowd (flickr)




  8
The battles to be won

 Performance & Scalability

 Productivity

 Extensibility

 Security

 Platform Maturity & Skills
  (Total Cost of Ownership)
                               9
Technology stack under consideration

 JEE 5 on standard JEE container

 Ruby 1.8.7 (MRI) + Rails 2.3.5 on
  standard RoR container

 JRuby 1.5.0 (Ruby 1.8.7) + Rails 2.3.5 on
  standard JEE container


                                              10
Performance & Scalability




                            11
Mumbai at sleep hours…                           Mumbai at peak hours…




                   “Architect to Scale”




Pune way back in my college days…   Pune on my way to RubyConfIndia 2012
                                                                      12
“Languages don’t scale, architectures do”
                                     - (someone wise)




                                                        13
Twitter bird (flickr)
Perf. &
                                                                                      Scale
  Threading & Parallel Processing




[Concurrency is a Myth in Ruby by Ilya Grigorik]
                                                                       JRuby

Thanks to Ilya Grigorik, Evan Phoenix (Ruby, Concurrency, and You) & Sasada Koichi (YARV)
for demystifying the concurrency & parallelism in Ruby implementations…                     14
Perf. &
                                                         Scale
       Memory Management




                              JRuby:
Ruby 1.8 (MRI):               More init mem. util (-), JVM GC
Stop the world, mark & sweep optimized to death over the
                              years. E.g.Min. GC pauses using
Ruby 1.9.3 (YARV): Lazy sweep multi- cores, or….or….(++)
garbage truck (flickr)                                            15
Perf. &
                                                       Scale
Code Execution Mechanism




 Ruby 1.8



              Ruby 1.9                            JRuby




    - Charles Nutter, Learning More About JRuby             16
The battlefield………




                     17
Perf. &
                                                               Scale
 Caching
Data store ~ bottleneck
Caching = Don’t hit bottleneck. Closer is faster.

                                                      JRoR
               JEE                     RoR
                                                    @CustCollab
 Session, application scope:  Memcached:  Simple, fast JEE
 • No i/o, protocol for in-memory    +1 breakpoint, cache
 • Auto expiry                       +1 component  Options++
 • App. server’s high availability  Cache’s HA to
   (HA) = cache’s HA                 be architected
Scale out options: Ehcache, …      Page, view,
Page, view, fragment scope etc.   fragment
                                   scope etc.


                                                                    18
Perf. &
                                                                      Scale
 Advanced Database Connection Pooling

require ‘reliable/db/pooling’
handle (spikes + heavy load + no load + failures)


       JEE containers          RoR containers            JRoR
 JDBC Pool + warm-up +        Pool + ?         JRuby AR-JDBC
  shrink + health ping +                          bridge enables
  recover leaked connections                      scalable + reliable db
  + monitor utilization =                         connection pool
  Scalable + Reliable




                                                                           19
Perf. &
                                                               Scale
 Asynchronous Messaging

Can’t remove bottlenecks?
Decouple them…

                                                      JRoR
         JEE                     RoR
                                                    @CustCollab
JMS:                 Good ones like ‘delayed job’  JMS planned
                      Evolving. As high QoS as       as message
• Stood the test of
                       JVM impls? Twitter FUD.        queue
  time…& money in
  large financial     No open std specs as such?
  institutions!        Product lock-in?
• High Quality of
  Service (QoS)



                                                                    20
Perf. &
                                                                               Scale
  JRuby+Java 7+new compiler: Future worth a mention




                                       +
 New Compiler: “Give the JVM better byte code.”                      Wow!
                                       +
“There will always be cases where we win or where we lose. Java 7's features
have made the win cases more frequent and more impressive. In general
if we are slower we consider it a bug and would like bug reports.”
[Sources: Charles Nutter, Learning More About JRuby & red/black tree benchmark ]
                                                                                   21
The battlefield………




                     22
Yeah, yeah.. but what about Productivity?




                                            23
Productivity

 Write Less, Do More
Every manager’s dream! Every programmer’s happiness!
Uhh? “programmer’s happiness”? = RoR 



           JEE                      RoR             JRoR @CustCollab
 You being smart isn’t                            Quick, feature rich
  enough …need smarter IDE   Genetically coded     releases
                              for the Next Gen
 Configuration is the        web...               Happy happy we
  Convention (seen web.xml                          shall be! When we
  of a large app?)                                  learn our JRuby!



                                             AJAX


                                                                           24
Extensibility




                25
Extensibility +
                                                             Productivity
 Multiple Response Formats

I want it NOW!
consumers = browsers + computers + smart phones +…aliens?



        JEE                 RoR               JRoR @CustCollab
  Not readily       Ready to eat XML,  Agile, XML based micro-
   cooked into the    JSON, RSS, ATOM     blogging API. Integrated
   framework                              w/ apps, BB, iOS devices



       <%= @messages.to_xml(:root => "messages") %>



                                                                         26
The battlefield………   27
Security




           28
Security +
                                                              Productivity
 SAML Single Sign-On

Don’t re-invent. Reuse.



       JEE                     RoR                JRoR @CustCollab
 Tested, ready to    Develop it or wait till    Reused the ready to
  use Java             someone else does. Then     use! That was fast!
  OpenSAML             customize it, test it.
  custom
  components in
  CustCollab




                                                                         29
Security +
                                                                    Optimization
 Session Management
Key to quality of service for good guys. Master key for bad guys.
Secure to death.

          JEE                       RoR                JRoR @CustCollab
  In-memory w/o           Cookie: 4 KB limit, not    Secure, high quality
   i/o, w/ auto-            b/w friendly,               of service session
   invalidation             vulnerable in principle     mgmt. = JEE
  Inherits app. server’s  AR: db queries +            session store
   high availability (HA)   cleanup daemon =
   architecture             (perf. + maint.)++         Vary session
                                                        timeout based on
  Session mgmt.           Memcached: +1               intranet or internet
   API: Set timeout         breakpoint + need to        using JEE session
   based on IP range        design HA + cleanup         mgmt. APIs
                            w/o persistent cookie


                                                                               30
Security +
                                                               Productivity
 Protection Against Security Threats
Built-in is better.

            JEE                     RoR            JRoR @CustCollab
 Protection against XSS,    XSS, SQL injection,  Micro-blogging
  SQL injection etc.          prepared stmts,       use case most
 CSRF protection? [JSF 2.2   CSRF…                 vulnerable to XSS,
  (WIP): strong, Servlet     Easy to use plug-ins, SQL injection,
  spec 3.1 (WIP?): yes?]      gems for others. E.g. CSRF. RoR
                              ReCAPTCHA             simplifies
                                                    protection.



      “protect_from_forgery” + “verify :method =>…”

                                                                         31
The battlefield………




                     32
All this is fine, but have you thought
about my Total Cost of Ownership?




                                         33
Total Cost of Ownership

 Alignment with Preferred Tech. Stack

= low total cost of ownership (TCO). Cost does matter.


      JEE                                       JRoR on JEE runtime
                     RoR @JavaJEEShop
  @JavaJEEShop                                    @JavaJEEShop
 Mature. Large       Simplicity =          JEE resources ramped up
  footprint in         Unconventionally       on RoR…real quick!
  enterprise world     short learning      Leveraged @CustCollab:
  & @CustCollab.       curve for            Apache mod_jk, Tomcat,
  Leverage dev,        programmers          build & deploy (war),
  ops skills,         Infra, ops, tools,   jVisualvm, Servlet filters,
  infra, tools =       evolving,…? = High   logging & analysis etc.
  Low TCO              TCO                 Low TCO


                                                                               34
& the battles are over…
so, who won the enter prize ?




                                35
36
@

    37
Hey, enough of dialogues!
 We want some action!




                            38
Seeing is Believing. Can it walk the talk?

 JRuby 1.5 (Ruby 1.8.7), Rails 2.3.5, deployed as a WAR file
  on Tomcat 6 with PostgreSQL 8.4 database.

 Target load (~50% of prod. estimate): 1500
  concurrent/active users in load test environment

 Response time target for transaction: 90th percentile
  should be < 2 to 3 seconds.

 Peak load steady state of 30 minutes.


                                                                39
 2 application servers: Each w/ RHEL, virtualized, Intel®
  Xeon® , 2 vCPUs, 3 GB RAM, 2 GB JVM heap size.

 Test data volume: 270,000+ micro-blogging channels,
  480,000+ micro-blogs.

 JRuby min and max runtimes = 1.

 Thread-safe code + “config.threadsafe!” in Rails.

Warm-up database connection pool to around 150.

On your mark…..get set…..

                                                             40
Rails is Happiness…




                         41
running…tracks(flickr)
& the result is…
 90th percentile of resp. time < 1.2 sec (!!), 100% passing
Throughput achieved:
 o ~127,800 primary requests in steady state (30 min) -
    (excludes secondary req like images, css, js)
  o ~ 71 primary requests/sec in steady state
CPU utilizations
 o Each application server <= 60%
 o Database server <= 20%
 RAM usage before test ~ RAM usage during & after test
 JVM heap space utilization ~ 85% in steady state (peak)
                                                            42
Quick facts…

Live in production.

Being used via web browser as well as from
 other apps & smart phones via micro-blogging
 API.

 Personal channels: 200,000+
 Communities (active than personal): 5000+
 Micro-blogs till Feb 2012: 224,000+
                                              43
Now enter the climax…




                        44
Hmmm…JRuby looks cool, isn’t it…
So, do you want to build fast & scalable applications?




                                       Silver
                                       Bullet
                                              =
                                                         45
Silver bullet (flickr)
Oops…
there
is
NO
silver
bullet

         46
buildFastScalableApp() {
  try {
         do {
            (estimate + architect + design + program).to_scale;
            assert_doesnt_scale? : don’t throw new hw($$$)  ;
            self.be_patient();
            everything.tune();
         } while (!scale && !tunedTheHellOutOfEverything);
  }//end try
  finally {
    if !scale? {
         throw new hw($$$) || throw new (arch && design) ||
         throw new (technology) || self.resign();
    }//end nightmare
    else {
         beer.overflow(); RubyConfIndia.talk()?;
    }//start celebrations
  }//end finally
}//end job                                                        47
&& while (that’s true)…

{
    Classy runtimes like JVM       ability to
    scale …rest is left up to the developer’s
    abilities & ENV[“constraints”]…
}




                                            48
&&

{
    Simple     languages     like    Ruby &
    Convention based frameworks like Rails
      productivity (more time to work on
    scalability :)...rest is left up to the
    developer’s            abilities      &
    ENV[“constraints”]…
}

                                          49
&&

{
    Classy, Simple, Convention based
    marriages like JRuby on Rails      ability
    to scale &&       productivity …rest is left
    up to you to arrange such a marriage
    that’s fast & will last in your
    ENV[“constraints”]…
}

                                                   50
finally {

  for (ENV[“CustCollab”]) {
     that.marriage = jruby + rails;
  }

}//end talk…almost



                                      51
Done? Where’s the little rhyming love
     song that was promised?




                                        52
‘Java + Ruby’ works just well…
Best of both is glued by the JRuby gel…

  Its fast… & will scale…
  Thanks JRuby, your promise didn’t fail!

                               - Darshan 



                                             53
A note of thanks to the backstage

o My colleague Yashasree Barve for letting me know abt
  RubyConfIndia CFP.

o RubyConfIndia for this opportunity!

o Manasee, my worried wife, for being cool with JRuby,
  Rails, MS ppt & me over all the weekends those followed
  my talk’s selection (she’s worried if I would ever finish
  preparing these slides & present them well…)


                                                              54
Artwork credits
oThe creative & open minds on flickr:
  o Mr. Ahmad Kavousian for officially permitting me to use
    his beautiful art work - /photos/kavous/2473202527/
  o Silver bullet - /photos/eschipul/4160817135/
  o People - /photos/kheelcenter/5279081507/
  o Twitter bird - /photos/travelinlibrarian/4329755033/
  o Garbage truck - /photos/jeffyoungstrom/3602384021/
  o Rain drops - /photos/photographygal123/4959951870/
  o Running along train tracks -
    /photos/seandreilinger/3167848378/


                                                              55
…& they lived happily ever after…




                                                 56
“On a rail track” by Ahmad Kavousian (flickr)
twitter.com/#!/dkarandikar




in.linkedin.com/in/darshankarandikar



                                       57

More Related Content

Viewers also liked

JRuby @ Boulder Ruby
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder Ruby
Nick Sieger
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyelliando dias
 
Jruby On Rails. Ruby on Rails en la JVM
Jruby On Rails. Ruby on Rails en la JVMJruby On Rails. Ruby on Rails en la JVM
Jruby On Rails. Ruby on Rails en la JVM
javier ramirez
 
Introduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsIntroduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsFramgia Vietnam
 
Developing api with rails metal
Developing api with rails metalDeveloping api with rails metal
Developing api with rails metalZack Siri
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on RailsFramgia Vietnam
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
Hiro Asari
 
Comparing JVM Web Frameworks - Devoxx 2010
Comparing JVM Web Frameworks - Devoxx 2010Comparing JVM Web Frameworks - Devoxx 2010
Comparing JVM Web Frameworks - Devoxx 2010
Matt Raible
 

Viewers also liked (11)

JRuby @ Boulder Ruby
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder Ruby
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
 
Jruby On Rails. Ruby on Rails en la JVM
Jruby On Rails. Ruby on Rails en la JVMJruby On Rails. Ruby on Rails en la JVM
Jruby On Rails. Ruby on Rails en la JVM
 
Introduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsIntroduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on Rails
 
Developing api with rails metal
Developing api with rails metalDeveloping api with rails metal
Developing api with rails metal
 
Rest and Rails
Rest and RailsRest and Rails
Rest and Rails
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on Rails
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Comparing JVM Web Frameworks - Devoxx 2010
Comparing JVM Web Frameworks - Devoxx 2010Comparing JVM Web Frameworks - Devoxx 2010
Comparing JVM Web Frameworks - Devoxx 2010
 

Similar to JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)

Euruko 2012 - JRuby
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRuby
Charles Nutter
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
Brian Sam-Bodden
 
Erjang - A journey into Erlang-land
Erjang - A journey into Erlang-landErjang - A journey into Erlang-land
Erjang - A journey into Erlang-land
Kresten Krab Thorup
 
JRuby and Google App Engine
JRuby and Google App EngineJRuby and Google App Engine
JRuby and Google App Engine
joshsmoore
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
ThoughtWorks
 
GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?
Arun Gupta
 
JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)
Charles Nutter
 
Jax keynote
Jax keynoteJax keynote
Jax keynote
Marcus Lagergren
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of Ruby
Uday Bhaskar
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
Thomas Lundström
 
Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012
Charles Nutter
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
Barry Jones
 
Challenges in Maintaining a High Performance Search Engine Written in Java
Challenges in Maintaining a High Performance Search Engine Written in JavaChallenges in Maintaining a High Performance Search Engine Written in Java
Challenges in Maintaining a High Performance Search Engine Written in Java
lucenerevolution
 
Dynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFishDynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFish
IndicThreads
 
Why we (Day) open source most of our code
Why we (Day) open source most of our codeWhy we (Day) open source most of our code
Why we (Day) open source most of our code
Bertrand Delacretaz
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoaThilo Utke
 
Rails On Spring
Rails On SpringRails On Spring
Rails On Spring
swamy g
 
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
Raimonds Simanovskis
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
David Keener
 

Similar to JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point) (20)

Euruko 2012 - JRuby
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRuby
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Erjang - A journey into Erlang-land
Erjang - A journey into Erlang-landErjang - A journey into Erlang-land
Erjang - A journey into Erlang-land
 
MacRuby
MacRubyMacRuby
MacRuby
 
JRuby and Google App Engine
JRuby and Google App EngineJRuby and Google App Engine
JRuby and Google App Engine
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
 
GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?GlassFish can support multiple Ruby frameworks ... really ?
GlassFish can support multiple Ruby frameworks ... really ?
 
JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)
 
Jax keynote
Jax keynoteJax keynote
Jax keynote
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of Ruby
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012Why JRuby? - RubyConf 2012
Why JRuby? - RubyConf 2012
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
Challenges in Maintaining a High Performance Search Engine Written in Java
Challenges in Maintaining a High Performance Search Engine Written in JavaChallenges in Maintaining a High Performance Search Engine Written in Java
Challenges in Maintaining a High Performance Search Engine Written in Java
 
Dynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFishDynamic Languages & Web Frameworks in GlassFish
Dynamic Languages & Web Frameworks in GlassFish
 
Why we (Day) open source most of our code
Why we (Day) open source most of our codeWhy we (Day) open source most of our code
Why we (Day) open source most of our code
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
 
Rails On Spring
Rails On SpringRails On Spring
Rails On Spring
 
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
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 

Recently uploaded

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 

Recently uploaded (20)

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 

JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)

  • 1. 1
  • 2. Once upon a time… powerful Java on their beautiful Ruby way to win the plot to unfold Enterprize battles to be won when Java, Ruby tried to win battles on their own… there were happy times… …& some down times… ……. then comes the time… Java falls in love with Ruby… (a little rhyming love song…I promise) now wait for the climax… No background music Fast & dramatic No popcorn break 2
  • 3. The script writer & confessions… x I’m neither too deep into Ruby nor have I run too far onto Rails so far But I love its Simplicity  I think & code in usual Java & JEE And I love its Class  I architect & code solutions at TCS  Thrilled to talk about JRuby when one of it’s creators & a JRuby hero is here! (Unbelievable!) x I tried, but couldn’t further shorten title of this story… 3
  • 4. The plot Micro-blogging @CustCollab API Search Public/private/ corporate/auto Profiles follow communities Smart Follow, unfollow, phones Micro-blogging invites etc. Pretty std notifications deply arch with Usage DMZ expected to Timelines, over a period threads, hashtags 200,000+ total users & Notifications from other apps 4
  • 5. The actors supporting Java & Ruby /* * @author #jruby.org */ public class JRuby implements Ruby { /* * This implementation of Ruby programming * language brings class to Ruby/Rails * & simplicity to Java/JEE. */ … } 5
  • 6. “Ruby on Rails® is an open-source web framework that's optimized for programmer's happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.” - rubyonrails.org 6 “On a rail track” by Ahmad Kavousian (flickr)
  • 7. Is it the Silver Bullet? 7 Silver bullet (flickr)
  • 9. The battles to be won  Performance & Scalability  Productivity  Extensibility  Security  Platform Maturity & Skills (Total Cost of Ownership) 9
  • 10. Technology stack under consideration  JEE 5 on standard JEE container  Ruby 1.8.7 (MRI) + Rails 2.3.5 on standard RoR container  JRuby 1.5.0 (Ruby 1.8.7) + Rails 2.3.5 on standard JEE container 10
  • 12. Mumbai at sleep hours… Mumbai at peak hours… “Architect to Scale” Pune way back in my college days… Pune on my way to RubyConfIndia 2012 12
  • 13. “Languages don’t scale, architectures do” - (someone wise) 13 Twitter bird (flickr)
  • 14. Perf. & Scale Threading & Parallel Processing [Concurrency is a Myth in Ruby by Ilya Grigorik] JRuby Thanks to Ilya Grigorik, Evan Phoenix (Ruby, Concurrency, and You) & Sasada Koichi (YARV) for demystifying the concurrency & parallelism in Ruby implementations… 14
  • 15. Perf. & Scale Memory Management JRuby: Ruby 1.8 (MRI): More init mem. util (-), JVM GC Stop the world, mark & sweep optimized to death over the years. E.g.Min. GC pauses using Ruby 1.9.3 (YARV): Lazy sweep multi- cores, or….or….(++) garbage truck (flickr) 15
  • 16. Perf. & Scale Code Execution Mechanism Ruby 1.8 Ruby 1.9 JRuby - Charles Nutter, Learning More About JRuby 16
  • 18. Perf. & Scale Caching Data store ~ bottleneck Caching = Don’t hit bottleneck. Closer is faster. JRoR JEE RoR @CustCollab  Session, application scope:  Memcached:  Simple, fast JEE • No i/o, protocol for in-memory +1 breakpoint, cache • Auto expiry +1 component  Options++ • App. server’s high availability  Cache’s HA to (HA) = cache’s HA be architected Scale out options: Ehcache, …  Page, view, Page, view, fragment scope etc. fragment scope etc. 18
  • 19. Perf. & Scale Advanced Database Connection Pooling require ‘reliable/db/pooling’ handle (spikes + heavy load + no load + failures) JEE containers RoR containers JRoR  JDBC Pool + warm-up + Pool + ?  JRuby AR-JDBC shrink + health ping + bridge enables recover leaked connections scalable + reliable db + monitor utilization = connection pool Scalable + Reliable 19
  • 20. Perf. & Scale Asynchronous Messaging Can’t remove bottlenecks? Decouple them… JRoR JEE RoR @CustCollab JMS: Good ones like ‘delayed job’  JMS planned Evolving. As high QoS as as message • Stood the test of JVM impls? Twitter FUD. queue time…& money in large financial No open std specs as such? institutions! Product lock-in? • High Quality of Service (QoS) 20
  • 21. Perf. & Scale JRuby+Java 7+new compiler: Future worth a mention + New Compiler: “Give the JVM better byte code.” Wow! + “There will always be cases where we win or where we lose. Java 7's features have made the win cases more frequent and more impressive. In general if we are slower we consider it a bug and would like bug reports.” [Sources: Charles Nutter, Learning More About JRuby & red/black tree benchmark ] 21
  • 23. Yeah, yeah.. but what about Productivity? 23
  • 24. Productivity Write Less, Do More Every manager’s dream! Every programmer’s happiness! Uhh? “programmer’s happiness”? = RoR  JEE RoR JRoR @CustCollab  You being smart isn’t  Quick, feature rich enough …need smarter IDE Genetically coded releases for the Next Gen  Configuration is the web...  Happy happy we Convention (seen web.xml shall be! When we of a large app?) learn our JRuby! AJAX 24
  • 26. Extensibility + Productivity Multiple Response Formats I want it NOW! consumers = browsers + computers + smart phones +…aliens? JEE RoR JRoR @CustCollab  Not readily Ready to eat XML,  Agile, XML based micro- cooked into the JSON, RSS, ATOM blogging API. Integrated framework w/ apps, BB, iOS devices <%= @messages.to_xml(:root => "messages") %> 26
  • 28. Security 28
  • 29. Security + Productivity SAML Single Sign-On Don’t re-invent. Reuse. JEE RoR JRoR @CustCollab  Tested, ready to  Develop it or wait till  Reused the ready to use Java someone else does. Then use! That was fast! OpenSAML customize it, test it. custom components in CustCollab 29
  • 30. Security + Optimization Session Management Key to quality of service for good guys. Master key for bad guys. Secure to death. JEE RoR JRoR @CustCollab  In-memory w/o  Cookie: 4 KB limit, not  Secure, high quality i/o, w/ auto- b/w friendly, of service session invalidation vulnerable in principle mgmt. = JEE  Inherits app. server’s  AR: db queries + session store high availability (HA) cleanup daemon = architecture (perf. + maint.)++  Vary session timeout based on  Session mgmt.  Memcached: +1 intranet or internet API: Set timeout breakpoint + need to using JEE session based on IP range design HA + cleanup mgmt. APIs w/o persistent cookie 30
  • 31. Security + Productivity Protection Against Security Threats Built-in is better. JEE RoR JRoR @CustCollab  Protection against XSS,  XSS, SQL injection,  Micro-blogging SQL injection etc. prepared stmts, use case most  CSRF protection? [JSF 2.2 CSRF… vulnerable to XSS, (WIP): strong, Servlet  Easy to use plug-ins, SQL injection, spec 3.1 (WIP?): yes?] gems for others. E.g. CSRF. RoR ReCAPTCHA simplifies protection. “protect_from_forgery” + “verify :method =>…” 31
  • 33. All this is fine, but have you thought about my Total Cost of Ownership? 33
  • 34. Total Cost of Ownership Alignment with Preferred Tech. Stack = low total cost of ownership (TCO). Cost does matter. JEE JRoR on JEE runtime RoR @JavaJEEShop @JavaJEEShop @JavaJEEShop  Mature. Large  Simplicity =  JEE resources ramped up footprint in Unconventionally on RoR…real quick! enterprise world short learning  Leveraged @CustCollab: & @CustCollab. curve for Apache mod_jk, Tomcat, Leverage dev, programmers build & deploy (war), ops skills,  Infra, ops, tools, jVisualvm, Servlet filters, infra, tools = evolving,…? = High logging & analysis etc. Low TCO TCO  Low TCO 34
  • 35. & the battles are over… so, who won the enter prize ? 35
  • 36. 36
  • 37. @ 37
  • 38. Hey, enough of dialogues! We want some action! 38
  • 39. Seeing is Believing. Can it walk the talk?  JRuby 1.5 (Ruby 1.8.7), Rails 2.3.5, deployed as a WAR file on Tomcat 6 with PostgreSQL 8.4 database.  Target load (~50% of prod. estimate): 1500 concurrent/active users in load test environment  Response time target for transaction: 90th percentile should be < 2 to 3 seconds.  Peak load steady state of 30 minutes. 39
  • 40.  2 application servers: Each w/ RHEL, virtualized, Intel® Xeon® , 2 vCPUs, 3 GB RAM, 2 GB JVM heap size.  Test data volume: 270,000+ micro-blogging channels, 480,000+ micro-blogs.  JRuby min and max runtimes = 1.  Thread-safe code + “config.threadsafe!” in Rails. Warm-up database connection pool to around 150. On your mark…..get set….. 40
  • 41. Rails is Happiness… 41 running…tracks(flickr)
  • 42. & the result is…  90th percentile of resp. time < 1.2 sec (!!), 100% passing Throughput achieved: o ~127,800 primary requests in steady state (30 min) - (excludes secondary req like images, css, js) o ~ 71 primary requests/sec in steady state CPU utilizations o Each application server <= 60% o Database server <= 20%  RAM usage before test ~ RAM usage during & after test  JVM heap space utilization ~ 85% in steady state (peak) 42
  • 43. Quick facts… Live in production. Being used via web browser as well as from other apps & smart phones via micro-blogging API.  Personal channels: 200,000+ Communities (active than personal): 5000+ Micro-blogs till Feb 2012: 224,000+ 43
  • 44. Now enter the climax… 44
  • 45. Hmmm…JRuby looks cool, isn’t it… So, do you want to build fast & scalable applications? Silver Bullet = 45 Silver bullet (flickr)
  • 47. buildFastScalableApp() { try { do { (estimate + architect + design + program).to_scale; assert_doesnt_scale? : don’t throw new hw($$$)  ; self.be_patient(); everything.tune(); } while (!scale && !tunedTheHellOutOfEverything); }//end try finally { if !scale? { throw new hw($$$) || throw new (arch && design) || throw new (technology) || self.resign(); }//end nightmare else { beer.overflow(); RubyConfIndia.talk()?; }//start celebrations }//end finally }//end job 47
  • 48. && while (that’s true)… { Classy runtimes like JVM ability to scale …rest is left up to the developer’s abilities & ENV[“constraints”]… } 48
  • 49. && { Simple languages like Ruby & Convention based frameworks like Rails productivity (more time to work on scalability :)...rest is left up to the developer’s abilities & ENV[“constraints”]… } 49
  • 50. && { Classy, Simple, Convention based marriages like JRuby on Rails ability to scale && productivity …rest is left up to you to arrange such a marriage that’s fast & will last in your ENV[“constraints”]… } 50
  • 51. finally { for (ENV[“CustCollab”]) { that.marriage = jruby + rails; } }//end talk…almost 51
  • 52. Done? Where’s the little rhyming love song that was promised? 52
  • 53. ‘Java + Ruby’ works just well… Best of both is glued by the JRuby gel… Its fast… & will scale… Thanks JRuby, your promise didn’t fail! - Darshan  53
  • 54. A note of thanks to the backstage o My colleague Yashasree Barve for letting me know abt RubyConfIndia CFP. o RubyConfIndia for this opportunity! o Manasee, my worried wife, for being cool with JRuby, Rails, MS ppt & me over all the weekends those followed my talk’s selection (she’s worried if I would ever finish preparing these slides & present them well…) 54
  • 55. Artwork credits oThe creative & open minds on flickr: o Mr. Ahmad Kavousian for officially permitting me to use his beautiful art work - /photos/kavous/2473202527/ o Silver bullet - /photos/eschipul/4160817135/ o People - /photos/kheelcenter/5279081507/ o Twitter bird - /photos/travelinlibrarian/4329755033/ o Garbage truck - /photos/jeffyoungstrom/3602384021/ o Rain drops - /photos/photographygal123/4959951870/ o Running along train tracks - /photos/seandreilinger/3167848378/ 55
  • 56. …& they lived happily ever after… 56 “On a rail track” by Ahmad Kavousian (flickr)