Browse Source

[rails] Increase connection pool to total of threads (#8514)

Currently the connection pool size is set to the number of threads per
worker: 5. The database connection pool size should equal:

    number_of_workers * threads_per_worker

Use the autotune script to get these values.
See also: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#database-connections

Also set the MIN_WORKERS to 2, like all other Ruby frameworks.
Now when verifying only 3 workers get started instead of 15.
Petrik de Heus 1 year ago
parent
commit
43761fca4a

+ 1 - 1
frameworks/Ruby/rails/config/auto_tune.rb

@@ -6,7 +6,7 @@
 require 'etc'
 require 'etc'
 
 
 KB_PER_WORKER = 128 * 1_024 # average of peak PSS of single-threaded processes (watch smem -k)
 KB_PER_WORKER = 128 * 1_024 # average of peak PSS of single-threaded processes (watch smem -k)
-MIN_WORKERS = 15
+MIN_WORKERS = 2
 MAX_WORKERS_PER_VCPU = 1.25 # virtual/logical
 MAX_WORKERS_PER_VCPU = 1.25 # virtual/logical
 MIN_THREADS_PER_WORKER = 1
 MIN_THREADS_PER_WORKER = 1
 MAX_THREADS = Integer(ENV['MAX_CONCURRENCY'] || 256)
 MAX_THREADS = Integer(ENV['MAX_CONCURRENCY'] || 256)

+ 1 - 1
frameworks/Ruby/rails/config/database.yml

@@ -5,7 +5,7 @@ default: &default
   password: benchmarkdbpass
   password: benchmarkdbpass
   host: tfb-database
   host: tfb-database
   timeout: 5000
   timeout: 5000
-  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+  pool: <%= require_relative 'auto_tune'; auto_tune.reduce(:*) %>
 
 
 development:
 development:
   <<: *default
   <<: *default