Nick Sieger: JRuby on Rails: Fast Enough tag:blog.nicksieger.com,2005:Typo Typo 2010-11-22T18:28:46+00:00 Raphaël Valyi urn:uuid:a0913c96-6266-4c56-9321-7440c4d93b1f 2007-10-26T09:55:43+00:00 2010-11-22T18:28:46+00:00 Comment on JRuby on Rails: Fast Enough by Raphaël Valyi <p>Cool!</p> <p>I observed the same kind of asymptotic warm up curve in my project with JRuby&#46; Warm up is a very long stage but perfom well ultimately which is what matters on the server side&#46;</p> <p>But really I would be curious to see your results with Java 6&#46; I can confirm it&#8217;s much faster&#46; On some J2EE project I saw a 30% speed increase on pure Java code&#46;</p> <p>Still, your results are a bit ambiguous&#46; Indeed, you are telling JRuby achieves the same speed as C&#45;Ruby but in a way you give it one more CPU even if request are not concurrent&#46; So may be you could show your results disabling the second CPU or may be you could insist more on this point&#46;</p> <p>Anyway, I&#8217;m very optimistic about JRuby&#8217;s future&#46; And also, Java integration by itself is already a win and optimizing bottlenecks in Java is also a clear win&#46;</p> <p>Best Regards</p> Nick Sieger urn:uuid:bfda082f-fa26-41d8-aa16-fc07b41aba35 2007-10-25T03:36:00+00:00 2010-11-22T18:07:00+00:00 JRuby on Rails: Fast Enough <p>People have been asking for a while how fast JRuby runs Rails&#46; (Of course, &#8220;fast&#8221; has always been a <a href="http://www.joelonsoftware.com/items/2006/09/12.html">relative term</a>&#46;) We haven&#8217;t been quick to answer the question, because frankly we didn&#8217;t know&#46; We hadn&#8217;t been building real Rails applications on JRuby ourselves yet, and there was no definitive word from the crowd either&#46;</p> <p>Recently, several guys from <a href="http://studios.thoughtworks.com/rubyworks">ThoughtWorks</a> have been working on a <a href="http://tw-commons.rubyforge.org/svn/petstore/trunk/">Rails petstore</a> application and benchmark to get to the heart of the matter&#46; <a href="http://www.nabble.com/forum/Search.jtp?forum=14106&amp;local=y&amp;query=petstore">Discussion has been heated</a> on the JRuby mailing list, but results have not been conclusive yet&#46;</p> <p>In the project I&#8217;m working on, we&#8217;ve <a href="http://blog.nicksieger.com/articles/2007/10/06/railsconf-europe-hydra">committed to using and deploying on JRuby</a>&#46; Eventually we were going to reach the point where we&#8217;d need to find out how well our application runs&#46; So today I began running a simple single request benchmark on a relatively busy page&#46; The numbers turned out to be rather surprising:</p> <p><img src="/files/jr-requests.png" alt="Requests" title="Requests"/></p> <p><img src="/files/jr-average.png" alt="Average" title="Average"/></p> <p>(The <a href="http://spreadsheets.google.com/pub?key=pGobleZnKsdI1zW38xpNaaw">raw data is available here</a>&#46;)</p> <p>Now, MRI (C Ruby) will always run about the same speed no matter how many runs you give it, but it&#8217;s well known that the JVM <a href="http://www.javaworld.com/javaworld/javaqa/2003-04/01-qa-0411-hotspot.html">needs time to warm up</a>&#46; And indeed it does; after 250 iterations, Mongrel running on JRuby finally surpasses MRI&#46; The JRuby/Goldspike/Glassfish combo comes close as well&#46;</p> <p>Some details about the setup:</p> <ul> <li>I ran the tests on my MacBook Pro Core 2 Duo 2&#46;4 GHz&#46; I didn&#8217;t disable one of the cores for the tests, which means that JRuby has an advantage over MRI because it can use both (native threads at work)&#46; However, the test script ran the requests serially, which means that the advantage was minimal&#46;</li> <li>The application is indeed of the <a href="http://blog.nicksieger.com/articles/2007/10/06/railsconf-europe-hydra">&#8220;hydra&#8221;</a> variety; the setup is nearly identical to the second diagram on that page&#46; So a single request is passing through <strong>not one, but two</strong> Rails applications in addition to touching the database&#46; It rendered an HTML ERb view with data from an ActiveResource&#45;accessed RESTful service&#46; The applications are based on Rails 1&#46;2&#46;3&#46;</li> <li>MRI version is using Ruby 1&#46;8&#46;6 and Mongrel 1&#46;0&#46;1&#46;</li> <li>JRuby Mongrel is also version 1&#46;0&#46;1 (<a href="http://jxh.bingodisk.com/bingo/public/Hackdays/JRuby/">details on installing it here</a>)</li> <li>JRuby on Glassfish used Glassfish 2 and Goldspike 1&#46;4, deployed in war files via <a href="http://caldersphere.rubyforge.org/warbler">Warbler</a>&#46;</li> <li>The two JRuby setups used JDK 1&#46;5 and were tweaked to <a href="http://ola-bini.blogspot.com/2007/07/objectspace-to-have-or-not-to-have.html">disable ObjectSpace</a> and use the &#8220;server&#8221; VM (&#45;server argument to the JVM)&#46;</li> </ul> <p>The main point I wish to make with these numbers is that JRuby performance is there today, and still has room to grow&#46; There&#8217;s no longer any doubt in my mind&#46; Yes, this is a simplistic application benchmark run on a developer&#8217;s machine, but it&#8217;s a real application&#46; The test may not be exacting in precision, but I see enough in the numbers to believe that this will be replicable to production environments&#46; The plot thickens!</p>