{"id":172109,"date":"2013-03-10T19:12:04","date_gmt":"2013-03-10T15:12:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=172109"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=172109","title":{"rendered":"<span class=\"post_title\">\u0422\u043e\u043d\u043a\u043e\u0441\u0442\u0438 Rails 4 \u2014 Thread-Safety<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/57d\/1a7\/928\/57d1a792882c2ae176ae6f8758a83784.jpg\"\/><\/p>\n<p>  \u0412 Rails 4.0 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043e\u043f\u0446\u0438\u044f config.threadsafe! \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0436\u0435 \u043e\u043d\u0430 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442, \u043a\u0430\u043a \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 production \u0438 \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<hr\/>\n<p>   <b>C\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0446\u0438\u043a\u043b\u0430 \u00ab\u0422\u043e\u043d\u043a\u043e\u0441\u0442\u0438 Rails 4\u00bb<\/b>   <\/p>\n<ul>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/165355\/\">Cache digests<\/a><\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/167161\/\">Turbolinks<\/a><\/li>\n<li>Thread-Safety<\/li>\n<\/ul>\n<p>  <\/p>\n<hr\/>\n<p>  \u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 Aaron Patterson (Tenderlove) \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b <a href=\"http:\/\/tenderlovemaking.com\/2012\/06\/18\/removing-config-threadsafe.html\">\u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0441\u0432\u043e\u0435\u043c \u0431\u043b\u043e\u0433\u0435<\/a>. \u0412 \u043d\u0435\u0439 \u043e\u043d \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b \u043e\u0431 \u043e\u043f\u0446\u0438\u0438 <b>threadsafe<\/b> \u0432 \u0440\u0435\u043b\u044c\u0441\u0430\u0445 \u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u0440\u0435\u043b\u0438\u0437\u0435 Rails 4. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u043c \u044d\u043f\u0438\u0437\u043e\u0434\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u043e \u043d\u0435\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Rails 3 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c thready:<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ rails new thready $ cd thready        <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432 \u0438 \u043e\u0433\u043b\u044f\u0434\u0435\u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u043f\u0446\u0438\u044f \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430:<\/p>\n<p>  \/config\/environments\/production.rb  <\/p>\n<pre><code class=\"ruby\"># Enable threaded mode # config.threadsafe! <\/code><\/pre>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0432 \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0427\u0442\u043e \u0436\u0435 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0434\u0435\u043b\u0430\u0435\u0442? \u041f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <b>threadsafe!<\/b> \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043d\u0430\u0431\u043e\u0440\u0430 \u043e\u043f\u0446\u0438\u0439:<\/p>\n<pre><code class=\"ruby\">def threadsafe!                 @preload_frameworks = true    @cache_classes      = true    @dependency_loading = false   @allow_concurrency  = true    self                        end                           <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0435 3 \u043e\u043f\u0446\u0438\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e <i>\u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u0443\u044e<\/i> \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0432\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043e \u0447\u0430\u0441\u0442\u044f\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u043c <b>threadsafe<\/b>. \u2028<\/p>\n<p>  \u0427\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u043e\u043f\u0446\u0438\u044f,<b> allow_concurrency<\/b> \u043e\u0442\u0440\u0443\u0431\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f <b>Rack::Lock<\/b>. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 rake middleware \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e Rack::Lock \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0435\u0440\u0432\u044b\u0445 \u0441\u043b\u043e\u0435\u0432, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c:<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ rake middleware          use ActionDispatch::Static use Rack::Lock             # \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0435\u043a\u0430 \u043e\u043f\u0443\u0449\u0435\u043d\u0430. <\/code><\/pre>\n<p>  \u0412\u043a\u043b\u044e\u0447\u0438\u0432 \u043e\u043f\u0446\u0438\u044e threadsafe \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432: <\/p>\n<pre><code class=\"ruby\">$ rake middleware RAILS_ENV=production  <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e. \u0414\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u00ab\u0410 \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 Rack::Lock\u00bb \u0441\u0442\u043e\u0438\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/rack\/rack\/blob\/master\/lib\/rack\/lock.rb\">\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a> (<i>\u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0444\u0430\u0439\u043b \u0443\u0441\u043f\u0435\u043b \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/i>):<\/p>\n<p>  \/lib\/rack\/lock.rb  <\/p>\n<pre><code class=\"ruby\">require 'thread'          require 'rack\/body_proxy'                           module Rack                 class Lock                  FLAG = 'rack.multithread'.freeze                                                      def initialize(app, mutex = Mutex.new)       @app, @mutex = app, mutex                end                                                                                   def call(env)                                old, env[FLAG] = env[FLAG], false          @mutex.lock                                response = @app.call(env)                  response[2] = BodyProxy.new(response[2]) { @mutex.unlock }                                response                rescue Exception            @mutex.unlock             raise                   ensure                      env[FLAG] = old         end                     end                     end                       <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434 <b>call<\/b> \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 mutex \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u043b\u043e\u043a \u0441\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441. \u0414\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u044d\u0442\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441 \u043e\u0434\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c:\u2028<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"perl\">$ rails g controller foo bar <\/code><\/pre>\n<p>  \u0412 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0441\u044b\u043f\u0430\u0442\u044c \u043d\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442:<\/p>\n<p>  \/app\/controllers\/foo_controller.rb  <\/p>\n<pre><code class=\"ruby\">class FooController &lt; ApplicationController   def bar     sleep 1     render text: &quot;foobar\\n&quot;   end end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 development. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f WEBrick (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u043e\u043d \u0438 \u0435\u0441\u0442\u044c). \u0422\u0435\u043f\u0435\u0440\u044c, \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0430\u0439\u0442\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e curl:\u2028\u2028<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ curl http:\/\/localhost:3000\/foo\/bar foobar <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u043d\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u043c 5 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c &#038;, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/p>\n<pre><code class=\"ruby\">% repeat 5 (curl http:\/\/localhost:3000\/foo\/bar &) % foobar foobar foobar foobar foobar <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u043d\u043e, \u043d\u043e \u044d\u0442\u0438 5 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043f\u0440\u0438\u0448\u043b\u0438 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c, \u0437\u0430\u043d\u044f\u0432 \u0432 \u0441\u0443\u043c\u043c\u0435 5 \u0441\u0435\u043a\u0443\u043d\u0434. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.\u2028\u2028\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a \u043d\u0435\u043c\u0443 5 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<p>  \u2028\u2028terminal  <\/p>\n<pre><code class=\"ruby\">% rails s -e production % repeat 5 (curl http:\/\/localhost:3000\/foo\/bar &) <\/code><\/pre>\n<p>  \u0412\u0441\u0435 5 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u0434\u0443\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 threadsafe!, \u0438\u0437-\u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u043e\u0439 Rack::Lock \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0422\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e, \u0443\u0440\u0430!\u2028\u2028<\/p>\n<p>  \u041e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043a\u043e\u0434? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 rails-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Unicorn \u0438 Phusion Passenger \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u043d\u043e\u0433\u043e worker\u2019\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438.\u2028\u2028<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f Unicorn. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443:\u2028\u2028<\/p>\n<p>  \/Gemfile  <\/p>\n<pre><code class=\"ruby\"># Use unicorn as the app server gem 'unicorn' <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c bundle install. \u0422\u0435\u043f\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b unicorn \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f Rails-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 production:\u2028\u2028<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ unicorn -E production -p 3000 <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043d\u043e\u0432\u044c curl \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Unicorn c \u043e\u0434\u043d\u0438\u043c worker\u2019\u043e\u043c. \u0414\u043b\u044f Unicorn\u2019\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e mutex\u2019\u0430 \u0438 \u0441\u043b\u043e\u044f Rack::Lock. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043e\u043f\u0446\u0438\u044f <b>threadsafe! <\/b>\u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435: \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0442\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0442\u043a\u0443\u043f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u2028\u2028\u041d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0438\u0432\u0443\u044e, \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b. \u0422\u0430\u043a \u0447\u0442\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0445\u043e\u0440\u043e\u0448\u0435\u043d\u044c\u043a\u043e \u043e\u0442\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043d\u043e\u0441\u043e\u043c \u043d\u0430 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d! \u2028\u2028<\/p>\n<p>  \u0415\u0449\u0435 \u043e\u0434\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u043e\u043f\u0446\u0438\u044f <b>threadsafe! <\/b>\u043c\u043e\u0436\u0435\u0442 \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0432 \u0440\u0435\u043b\u0438\u0437\u0435 4 \u0440\u0435\u043b\u044c\u0441 \u0441 \u0446\u0435\u043b\u044c\u044e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b. <\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e Unicorn \u0438 Passenger \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0430 \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439? \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 puma. \u042d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 Mongrel, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 Rack-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. Puma \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 JRuby, Rubinius \u0438 \u0434\u0430\u0436\u0435 MRI. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:<\/p>\n<p>  \u2028\u2028\/Gemfile  <\/p>\n<pre><code class=\"ruby\"># Use unicorn as the app server # gem 'unicorn' gem 'puma' <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430:\u2028<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ rails s puma -e production <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0442\u0435\u043f\u0435\u0440\u044c curl \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u044b \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043f\u043e\u0447\u0442\u0438 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e.\u2028\u2028<\/p>\n<p>  Puma \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 MRI, \u0438\u0437-\u0437\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u0443 \u0432\u0435\u0440\u0441\u0438\u044e \u0440\u0443\u0431\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c Global Interpreter Lock. \u041d\u043e JRuby \u0438 Rubinius \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0442\u0430\u043a \u0447\u0442\u043e \u0432 \u043d\u0438\u0445 \u041f\u0443\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435.\u2028<\/p>\n<p>  \u2028\u2028\u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u043e\u0434\u043e\u043c \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0435\u0433\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e. \u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430:\u2028\u2028<\/p>\n<p>  \/app\/controllers\/foo_controller.rb  <\/p>\n<pre><code class=\"ruby\">class FooController &lt; ApplicationController   @@counter = 0   def bar     counter = @@counter     sleep 1     counter += 1     @@counter = counter     render text: &quot;#{@@counter}\\n&quot;   end end <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c @@counter, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u043d\u0430 1 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 bar. \u0412 \u0441\u0430\u043c\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0430, \u0441\u043f\u0438\u043c \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435:<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ rails s <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c curl 4 \u0440\u0430\u0437\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f 4 \u0446\u0438\u0444\u0440\u044b, \u043a\u0430\u0436\u0434\u0430\u044f \u2014 \u0441 \u0441\u0435\u043a\u0443\u043d\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439:\u2028<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">% repeat 4 (curl http:\/\/localhost:3000\/foo\/bar &) % 1 2 3 4 <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440, \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c Puma \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430:<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">$ rails s puma -e production <\/code><\/pre>\n<p>  \u0415\u0435 \u0432\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f:<\/p>\n<p>  terminal  <\/p>\n<pre><code class=\"ruby\">% repeat 4 (curl http:\/\/localhost:3000\/foo\/bar &) % 1 1 1 1 <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0441\u043f\u0435\u043b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u0435\u0449\u0435 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0441\u043f\u0435\u043b \u0434\u043e\u0432\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b\u043c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 (@@counter, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443), \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0442\u0438\u043f\u0430 mutex:\u2028<\/p>\n<p>  \/app\/controllers\/foo_controller.rb  <\/p>\n<pre><code class=\"ruby\">class FooController &lt; ApplicationController   @@counter = 0   @@mutex = Mutex.new    def bar     @@mutex.synchronize do       counter = @@counter       sleep 1       counter += 1       @@counter = counter     end     render text: &quot;#{@@counter}&quot;   end end <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u043c\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 mutex&#8217;\u043e\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u043d\u043e\u0432\u044c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f curl. \u0421\u0447\u0435\u0442\u0447\u0438\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u0434 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 mutex&#8217;\u0430. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0435\u0442\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432 \u0440\u0443\u0431\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c. \u041a\u0430\u043a \u0438 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u043f\u0440\u043e\u0447\u0435\u043c. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c freeze \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u0435\u0442\u0430 \u043d\u0430 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u0418 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f shared memory, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u043d\u0430\u0434\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0441\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0436 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432\u0430\u043c \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e \u0440\u0430\u0441\u0448\u0430\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0410 \u0435\u0441\u043b\u0438 \u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u0412\u043f\u043e\u043b\u043d\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0433\u0435\u043c\u044b \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e-\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b. \u041f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 README \u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u043d\u0443\u0436\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0435\u0442, \u0442\u043e \u0441\u0442\u043e\u0438\u0442, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0438\u043a\u0435\u0442 \u0432 \u0442\u0440\u0435\u043a\u0435\u0440\u0435.<\/p>\n<p>  \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u043e\u043d\u0430 \u0441 \u043f\u0443\u043b\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e\u0442 \u043f\u0443\u043b \u0437\u0430\u0434\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043a \u0431\u0434 \u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u0435\u043d 5. \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u044f \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u043b mutex.<\/p>\n<p>  \/app\/controllers\/foo_controller.rb  <\/p>\n<pre><code class=\"ruby\">def bar   #@@mutex.synchronize do     counter = @@counter     sleep 1     counter += 1     @@counter = counter   #end   render text: &quot;#{@@counter}\\n&quot; end <\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c 12 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e 4 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u043e\u0448\u043b\u0438, \u0438\u0437-\u0437\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0431\u0434, rails \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0418 \u0435\u0441\u043b\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u0432\u043e\u0435\u0433\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430\u0442\u044f\u043d\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u043e \u043d\u0430\u0447\u043d\u0443\u0442 \u0441\u044b\u043f\u0430\u0442\u044c\u0441\u044f timeout \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0442\u043e\u0436\u0435 \u043e\u0442\u0432\u0430\u043b\u044f\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0438\u0437 \u043f\u0443\u043b\u0430 \u0431\u0434.<\/p>\n<p>  \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u0443\u043b\u0435 \u0434\u043e 15, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 curl \u0438 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u043e\u0439\u0434\u0443\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e. <\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<h5><i>\u041d\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442 \u0430\u0432\u0442\u043e\u0440\u0430. \u041e\u0431\u043e \u0432\u0441\u0435\u0445 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044f\u0445 \u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043f\u0440\u043e\u0441\u044c\u0431\u0430 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u0432 \u043b\u0438\u0447\u043a\u0443.<\/i><\/h5>\n<p>  <\/p>\n<hr\/>\n<p>  <b>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/b>  <\/p>\n<ul>\n<li><a href=\"http:\/\/tenderlovemaking.com\/2012\/06\/18\/removing-config-threadsafe.html\">\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u043b\u043e\u0433\u0435 \u0410\u0430\u0440\u043e\u043d\u0430 \u043e\u0431 \u043e\u043f\u0446\u0438\u0438 config.threadsafe!<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/rack\/rack\/blob\/master\/lib\/rack\/lock.rb\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0434\u0443\u043b\u044f Rack::Lock<\/a><\/li>\n<li><a href=\"http:\/\/puma.io\/\">\u0421\u0435\u0440\u0432\u0435\u0440 Puma<\/a><\/li>\n<\/ul>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/172109\/\"> http:\/\/habrahabr.ru\/post\/172109\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/57d\/1a7\/928\/57d1a792882c2ae176ae6f8758a83784.jpg\"\/><\/p>\n<p>  \u0412 Rails 4.0 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043e\u043f\u0446\u0438\u044f config.threadsafe! \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0436\u0435 \u043e\u043d\u0430 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442, \u043a\u0430\u043a \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 production \u0438 \u043a\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-172109","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/172109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=172109"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/172109\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=172109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=172109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=172109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}