Browse Source

Add puma preloading, decrease DB pool size to size of threads per worker

pull/4/head
Eugen Rochko 6 years ago
parent
commit
e7723ab662
2 changed files with 5 additions and 5 deletions
  1. +1
    -1
      config/database.yml
  2. +4
    -4
      config/puma.rb

+ 1
- 1
config/database.yml View File

@ -1,6 +1,6 @@
default: &default
adapter: postgresql
pool: 17
pool: <%= ENV["DB_POOL"] || ENV['RAILS_MAX_THREADS'] || 5 %>
timeout: 5000
encoding: unicode

+ 4
- 4
config/puma.rb View File

@ -30,7 +30,7 @@ workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
@ -39,9 +39,9 @@ workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

Loading…
Cancel
Save