Created
November 25, 2018 03:15
-
-
Save bookmebus/e5f81fec0a1ba7128b79ce65e98032e5 to your computer and use it in GitHub Desktop.
ElasticBeanStalk custom puma config for multiprocess x workers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
container_commands: | |
# directory '/var/app/current' | |
# threads 8, 32 | |
# workers %x(grep -c processor /proc/cpuinfo) | |
# bind 'unix:///var/run/puma/my_app.sock' | |
# pidfile '/var/run/puma/puma.pid' | |
# stdout_redirect '/var/log/puma/puma.log', '/var/log/puma/puma.log', true | |
# daemonize false | |
01backup_config: | |
command: "cp -n /opt/elasticbeanstalk/support/conf/pumaconf.rb /opt/elasticbeanstalk/support/conf/pumaconf.rb.original" | |
02_edit_comment_default_threads_config: | |
# threads 8, 32 -> threads 4, 8 | |
command: "sed -i 's/threads 8, 32/threads 4, 8/' /opt/elasticbeanstalk/support/conf/pumaconf.rb" | |
03_delete_default_worker_config: | |
# workers %x(grep -c processor /proc/cpuinfo) -> workers 5 * %x( grep -c processor /proc/cpuinfo ).to_i | |
command: "sed -i '/workers/d' /opt/elasticbeanstalk/support/conf/pumaconf.rb" | |
04_insert_new_worker_after_threads_config: | |
command: "sed -i '/threads/a workers 5 * %x( grep -c processor /proc/cpuinfo ).to_i' /opt/elasticbeanstalk/support/conf/pumaconf.rb" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Elasticbeanstalk puma default configuration which resides in /opt/elasticbeanstalk/support/conf/pumaconf.rb
directory '/var/app/current'
threads 8, 32
workers %x(grep -c processor /proc/cpuinfo)
bind 'unix:///var/run/puma/my_app.sock'
pidfile '/var/run/puma/puma.pid'
stdout_redirect '/var/log/puma/puma.log', '/var/log/puma/puma.log', true
daemonize false
The number of workers is set to equal to the number cpu cores. If the instance RAM is big this config does not seem good enough especially for Large instance type with MRI Ruby. As suggested from puma docs:
number_of_threads = wanted_number_of_concurrency/number_of_workers