Skip to content

Commit

Permalink
Puma Worker Configuration (#1701)
Browse files Browse the repository at this point in the history
We noticed that the current default settings perform very poorly under
load. We managed to literally take down Greenlight during a larger event
when people where accessing the landing page for rooms and when doing
some tests, I was more or less able to DoS Greenlight on my own.

This patch adds a default worker configuration similar to the previous
configuration with one worker, but lets users easily adjust it to more
workers which significantly improves the situation. The small, 4 core
machine I was testing on could handle about thrice the amount of
requests.

Co-authored-by: Ahmad Farhat <ahmad.af.farhat@gmail.com>
  • Loading branch information
lkiesow and farhatahmad committed Sep 29, 2020
1 parent ba7beb8 commit 4286864
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
workers ENV.fetch("WEB_CONCURRENCY") { 1 }

# 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 `rails restart` command.
plugin :tmp_restart
14 changes: 13 additions & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ CABLE_ADAPTER=postgresql
DEFAULT_REGISTRATION=open

# Preupload Presentation Storage
#
#
# By default, if Preupload Presentation is enabled for rooms, presentations are uploaded locally to ~/greenlight/storage
# If you prefer to use AWS S3 or GCS Storage, you can set the variables below
#
Expand All @@ -287,3 +287,15 @@ DEFAULT_REGISTRATION=open
# GCS_CLIENT_CERT=
# GCS_PROJECT=
# GCS_BUCKET=

# Web server settings
#
# The size of the thread pool per worker used by Greenlight's web server.
# For details, see: https://github.com/puma/puma#thread-pool
# Default: 5
#RAILS_MAX_THREADS=5

# The amount of workers (separate processes) used by the web server.
# For details, see: https://github.com/puma/puma#clustered-mode
# Default: 1
#WEB_CONCURRENCY=1

0 comments on commit 4286864

Please sign in to comment.