diff --git a/Gemfile.lock b/Gemfile.lock index aefb50e315a36..a5cf0757f8556 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,7 @@ PATH activesupport (8.0.0.alpha) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) @@ -182,7 +182,7 @@ GEM cgi (0.4.1) chef-utils (18.3.0) concurrent-ruby - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.1) connection_pool (2.4.1) crack (0.4.5) rexml diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 17fb20f2a4c3d..4e4f6514925ea 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |s| s.add_dependency "i18n", ">= 1.6", "< 2" s.add_dependency "tzinfo", "~> 2.0", ">= 2.0.5" - s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" + s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.3.1" s.add_dependency "connection_pool", ">= 2.2.5" s.add_dependency "minitest", ">= 5.1" s.add_dependency "base64" diff --git a/railties/lib/rails/generators/rails/app/templates/config/puma.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/puma.rb.tt index e0364130c2e68..f976b8aa37112 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/puma.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/puma.rb.tt @@ -32,10 +32,9 @@ when "production" # If you are running more than 1 thread per process, the workers count # should be equal to the number of processors (CPU cores) in production. # - # It defaults to 1 because it's impossible to reliably detect how many - # CPU cores are available. Make sure to set the `WEB_CONCURRENCY` environment - # variable to match the number of processors. - workers_count = Integer(ENV.fetch("WEB_CONCURRENCY", 1)) + # Automatically detect the number of available processors in production. + require "concurrent-ruby" + workers_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.available_processor_count }) workers workers_count if workers_count > 1 preload_app!