title: Benefits of jRuby with Rails 4
body: <p>I'm currently considering moving to jRuby, and I'm still unsure how everything will work, but let's consider this hypothetical situation. </p>
  
  <p>A <code>user 1</code> loads a page in my app which takes about 2.5 seconds, and at about <code>500ms</code> in the execution a <code>user 2</code> tries to open different page which takes 1 second to load.</p>
  
  <p>If my estimate is correct, this is what would happen if you ran it in MRI with single process :</p>
  
  <ol>
  <li>User 1 waits for 2,5 seconds for his page to load</li>
  <li>User 2 waits for 3 seconds for his page to load (2 seconds waiting for user 1 to complete the loading of his page, and 1 second for his page to finish rendering)</li>
  </ol>
  
  <p>Is my estimate correct? </p>
  
  <p>And let's say if I ran the same app under jRuby this would happen :</p>
  
  <ol>
  <li>User 1 waits 2,5 seconds for his page to load</li>
  <li>User 2 waits for 1 or more seconds but less than 3, depending how much of the memory/cpu the request from user 1 takes</li>
  </ol>
  
  <p>Is my other estimate correct? Of course assuming your code is thread safe. If my estimate is incorrect please correct me, or if it is correct, do I need to make sure that some config is set at rails app level or should I be careful about something else other than thread safe code?</p>
  
  <h2>Update</h2>
  
  <p>I've just done a small jRuby POC app, used the warbler gem to build a war file, and deployed a war to a Tomcat web server. I don't think my estimate was correct for jRuby, this is what I observed :</p>
  
  <ol>
  <li>User 1 waits 2,5 seconds for his page to load</li>
  <li>User 2 waits for 3 seconds</li>
  </ol>
  
  <p>Which is identical to MRI, in terms of request processing, shouldn't jRuby process these in parallel?</p>