3
3

More than 3 years have passed since last update.

一度に複数のAPIリクエストを送るとRails serverがハングアップする

Last updated at Posted at 2020-05-12

現象

  • ローカルで一度に複数の API リクエストを送ると Rails server がハングアップする
    • Ctrl + C を押下してもプロセスを終了できなくなる
    • lsof コマンドと kill コマンドを実行するなどして、プロセス終了させる必要がある

再現した環境

解決方法

1. パッチを適用する

actionpack/lib/action_controller/metal/params_wrapper.rb
 def model
-  super || synchronize { super || self.model = _default_wrap_model }
+  super || self.model = _default_wrap_model
 end

2. eager_load を true にする

config/environments/development.rb
- config.eager_load = false
+ config.eager_load = true

3. puma の設定を変更する

config/puma.rb
- threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 1 }
3
3
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
3
3