diff --git a/.env-example b/.env-example index cc4ee09c86..42e2541580 100644 --- a/.env-example +++ b/.env-example @@ -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" \ No newline at end of file +DECIDIM_ADMIN_PASSWORD_STRONG="false" +# Puma server configuration +# PUMA_MIN_THREADS=5 +# PUMA_MAX_THREADS=5 +# PUMA_WORKERS=0 +# PUMA_PRELOAD_APP=false \ No newline at end of file diff --git a/config/puma.rb b/config/puma.rb index a8adec5d17..ba8a769a08 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -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. # @@ -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 \ No newline at end of file diff --git a/docker-compose.local.yml b/docker-compose.local.yml index f13ad1572f..65ee35b4a4 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -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 @@ -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: @@ -70,6 +80,6 @@ services: - memcached volumes: - app-data: { } + shared-volume: { } pg-data: { } redis-data: { } \ No newline at end of file