title: How Rails serves concurrent requests
body: <p>I will divide this question in <em>two parts</em>.<br>
  <strong>Part 1:</strong><br>
  How Rails serves concurrent requests to the same action?<br>
  Is Rails serves concurrent requests in <strong>different Threads</strong> or Rails serve in a <strong>queue</strong>?</p>
  
  <p><strong>Part 2:</strong><br>
  Why I ask?<br>
  I make a very specific project. And now I thinking about change the application architecture if necessary.</p>
  
  <h2>Question</h2>
  
  <p><strong>Foreword</strong><br>
  I have controller with action calculate. 
  It seems like that:  </p>
  
  <pre><code> def calculate
        first_player_code  = Code.find(params[:first_player_id])
        second_player_code = Code.find(params[:second_player_id])
        File.open("first_player_code.rb", "w"){|file| file &lt;&lt; first_player_code}
        File.open("second_player_code.rb", "w"){|file| file &lt;&lt; second_player_code}
        system("ruby calculate.rb")
   end
  </code></pre>
  
  <p><strong>calculate.rb</strong> is contains script, which uses files  "<strong>first_player_code.rb</strong>" and "<strong>second_player_code.rb</strong>".<br>
  This script make <strong>JSON</strong> file as result and send it to browser.</p>
  
  <p><strong>More information</strong><br>
  "<strong>first_player_code.rb</strong>" and "<strong>second_player_code.rb</strong>" contains Ruby classes.<br>
  In <strong>"calculate.rb"</strong> i <strong>requiring these files</strong> and <strong>making objects</strong> from classes, which are in these files.<br>
  I just didn't find another way to do this (without using Files).</p>
  
  <p><strong>The question itself</strong><br>
  Are there <strong>synchronization</strong> problems?</p>