Skip to content

Commit

Permalink
DEV-512: Puma and other performance-related improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
danschmidt5189 committed Mar 12, 2024
1 parent 0d50a15 commit 399e559
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 42 deletions.
29 changes: 0 additions & 29 deletions .bash_history

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.rbc
capybara-*.html
.bash*
.rspec
/db/*.sqlite3
/db/*.sqlite3-journal
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem 'jquery-rails'
gem 'omniauth-cas'
gem 'pg', '~> 1.4.6'
gem 'puma', '~> 5.0'
gem 'rack-timeout', '~> 0.6.3'
gem 'rails', '~> 7.0.4', '>= 7.0.4.3'
gem 'rsolr', '>= 1.0', '< 3'
gem 'sassc-rails', '~> 2.1'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ GEM
rack (2.2.8)
rack-test (2.1.0)
rack (>= 1.3)
rack-timeout (0.6.3)
rails (7.0.8)
actioncable (= 7.0.8)
actionmailbox (= 7.0.8)
Expand Down Expand Up @@ -502,6 +503,7 @@ DEPENDENCIES
omniauth-cas
pg (~> 1.4.6)
puma (~> 5.0)
rack-timeout (~> 0.6.3)
rails (~> 7.0.4, >= 7.0.4.3)
rsolr (>= 1.0, < 3)
rspec-rails
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = :info
config.log_level = :error

# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
Expand Down
18 changes: 6 additions & 12 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,34 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
threads_count = ENV.fetch('PUMA_THREADS', 5).to_i
threads threads_count, threads_count

# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch('PORT', 3000)

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch('RAILS_ENV') { 'development' }
environment ENV.fetch('RAILS_ENV', 'development')

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# 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") { 2 }
workers ENV.fetch('PUMA_WORKERS', 2).to_i

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
preload_app!

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart

0 comments on commit 399e559

Please sign in to comment.