From d5a98a0f9ef8f2c7ece1d487bb7017e5d6a28ed3 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 8 Mar 2025 16:11:11 +0200 Subject: [PATCH] web concurrency auto --- config/puma.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index 964a3298..ed99f0c9 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -33,8 +33,14 @@ environment ENV.fetch('RAILS_ENV', 'development') # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). -# -workers ENV.fetch('WEB_CONCURRENCY', 0) + +if ENV['WEB_CONCURRENCY_AUTO'] == 'true' + require 'etc' + + workers Etc.nprocessors +else + workers ENV.fetch('WEB_CONCURRENCY', 0) +end # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code