From e449c430a5699445e62ba0d579ae60968430b2c3 Mon Sep 17 00:00:00 2001 From: "Sakamoto, Kazunori" Date: Fri, 19 Apr 2024 00:31:14 +0900 Subject: [PATCH] fix: optimize puma configs --- config/puma.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index 8f549b05..37792182 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,15 +1,17 @@ -workers Integer(ENV['WEB_CONCURRENCY'] || 2) -threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 10) +workers Integer(ENV['WEB_CONCURRENCY'] || 4) +threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) threads threads_count, threads_count preload_app! rackup DefaultRackup port ENV['PORT'] || 3000 -environment ENV['RACK_ENV'] || 'development' +environment ENV['RACK_ENV'] || 'production' on_worker_boot do - # Worker specific setup for Rails 4.1+ - # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot ActiveRecord::Base.establish_connection end + +before_fork do + ActiveRecord::Base.connection_pool.disconnect! +end