Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Super slow performance after rails 4.2 upgrade

I recently upgraded rails from 4.0.4 to 4.2, and it's dependancies likewise. I run my application on a puma server, and I also upgraded the puma gem to the most recent stable release.

Problem is, after the upgrade, most of my request times went from 1-2 seconds, to 30+, resulting in Heroku timing out

Puma connection file

# Force heroku to bigger conenction pool
Rails.application.config.after_initialize do
  ActiveRecord::Base.connection_pool.disconnect!

  ActiveSupport.on_load(:active_record) do
    config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env]
    config['reaping_frequency'] = ENV['PUMA_DB_REAP_FREQ'] || 10 # Seconds
    config['pool']              = ENV['PUMA_DB_POOL'] || 20 # Puma can run up to 16 threads, perfect will be 80 (5x16), but heroku max is 20 for dev and basic
    ActiveRecord::Base.establish_connection(config)
  end
end

Gemfile (only relevant gems)

source 'https://rubygems.org'
ruby '2.0.0'
gem 'puma', '2.10.2'
gem 'rails', '~> 4.2.0'
gem 'pg', '~> 0.18.0'
gem 'heroku'
gem 'responders', '~> 2.0'

Any idea as to why this huge change in request times happened?

like image 601
Tarlen Avatar asked Jan 19 '15 17:01

Tarlen


1 Answers

There are some known issues for Rails 4.2.0 that have been addressed since this was posted including: https://github.com/rails/rails/issues/18029. The 4.2.1 release provides some improvements that might satisfy your needs better.

If you are running 4.2.1 with Engine Yard and are still experiencing trouble please file a ticket with Engine Yard Support so we can help you investigate this further.

like image 113
tpol Avatar answered Sep 22 '22 12:09

tpol