Tarlen
Tarlen

Reputation: 3797

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?

Upvotes: 11

Views: 2029

Answers (2)

mahemoff
mahemoff

Reputation: 46509

There's this Rack issue: https://github.com/rails/rails/issues/18828 which caused major slowdowns in development.

Apply the fix mentioned in that thread: "With options[:OutputBufferSize] = 5 commented out of rack-1.6.0/lib/rack/handler/webrick.rb".

You could alternatively edit your Gemfile and update Rack to be served from the master github repo too, now that it's been patched. It should be fixed in the next Rails release (4.2.2 presumably).

Upvotes: 0

tpol
tpol

Reputation: 301

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.

Upvotes: 2

Related Questions