Skip to content

Commit 839ac1e

Browse files
authored
Use worker count equal to processor count in production (rails#46838)
1 parent afbde03 commit 839ac1e

File tree

1 file changed

+6
-0
lines changed
  • railties/lib/rails/generators/rails/app/templates/config

1 file changed

+6
-0
lines changed

railties/lib/rails/generators/rails/app/templates/config/puma.rb.tt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
1111
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
1212
threads min_threads_count, max_threads_count
1313

14+
# Specifies that the worker count should equal the number of processors in production.
15+
if ENV["RAILS_ENV"] == "production"
16+
worker_count = ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }
17+
workers worker_count if worker_count > 1
18+
end
19+
1420
# Specifies the `worker_timeout` threshold that Puma will use to wait before
1521
# terminating a worker in development environments.
1622
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

0 commit comments

Comments
 (0)