Skip to content

Commit

Permalink
fix: Fine tuning puma on docker-compose local
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Oct 30, 2023
1 parent a9f0db7 commit 3aba6bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
7 changes: 6 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ DEFACE_ENABLED=false
DECIDIM_ADMIN_PASSWORD_EXPIRATION_DAYS=365
DECIDIM_ADMIN_PASSWORD_MIN_LENGTH=15
DECIDIM_ADMIN_PASSWORD_REPETITION_TIMES=5
DECIDIM_ADMIN_PASSWORD_STRONG="false"
DECIDIM_ADMIN_PASSWORD_STRONG="false"
# Puma server configuration
# PUMA_MIN_THREADS=5
# PUMA_MAX_THREADS=5
# PUMA_WORKERS=0
# PUMA_PRELOAD_APP=false
16 changes: 9 additions & 7 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# Any libraries that use thread pools should be configured to match
# 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.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
threads threads_count, threads_count

min_threads_count = ENV.fetch("PUMA_MIN_THREADS", 5).to_i
max_threads_count = ENV.fetch("PUMA_MAX_THREADS", 5).to_i
threads min_threads_count, max_threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
Expand All @@ -22,15 +23,16 @@
# 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_count = ENV.fetch("PUMA_WORKERS", -1).to_i
workers workers_count if workers_count.positive?

# 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! if ENV.fetch("PUMA_PRELOAD_APP", "false") == "true"

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
plugin :tmp_restart
16 changes: 13 additions & 3 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ services:
- SEED=true
- DEFACE_ENABLED=false
- QUESTION_CAPTCHA_HOST=
- ENABLE_RACK_ATTACK=0
- PUMA_MIN_THREADS=5
- PUMA_MAX_THREADS=5
- PUMA_WORKERS=4
- PUMA_PRELOAD_APP=true
depends_on:
- app
volumes:
- .:/app
- shared-volume:/app
links:
- database
- redis
Expand All @@ -60,8 +65,13 @@ services:
- SEED=true
- DEFACE_ENABLED=false
- QUESTION_CAPTCHA_HOST=
- ENABLE_RACK_ATTACK=0
- PUMA_MIN_THREADS=5
- PUMA_MAX_THREADS=5
- PUMA_WORKERS=4
- PUMA_PRELOAD_APP=true
volumes:
- .:/app
- shared-volume:/app
ports:
- 3000:3000
depends_on:
Expand All @@ -70,6 +80,6 @@ services:
- memcached

volumes:
app-data: { }
shared-volume: { }
pg-data: { }
redis-data: { }

0 comments on commit 3aba6bb

Please sign in to comment.