4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NextremerAdvent Calendar 2017

Day 17

HerokuのデプロイしたRailsアプリにPumaを導入してみる

Posted at

Pumaとは

スレッドベースで動作することにより並列処理を行ってくれるWebサーバです。

Pumaのインストール

Gemfile
gem 'puma'

Procfile

Procfile
web: bundle exec puma -C config/puma.rb

pumaの設定

config/puma.rb
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

Worker数

dynoの一つにつきworkerを増やせるかはメモリ使用量によるがfree, hobby,standard-1xのプランだと2-4が目安とのこと。
可能なメモリの上限を超えた時に生じるR14 errorsを監視して設定することをオススメします。

Threads数

thread数の上限と下限を設定できるが、heroku的には同じ値を設定するのがお勧めとのこと。

参考サイト

Deploying Rails Applications with the Puma Web Server

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?