I have an app based on Rails 3 (version Rails 3.1.2) and ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]. The loading of the app is so slow, right now, when I tried it, I was waiting 23 seconds, than the index page was loaded. It is the same as on the Heroku as on the localhost.
I found similar topics here on SO, but unfortunately I didn’t find there a solution that would solve my problem. Somewhere on a blog I read, that this problem could be caused, because the page no one long time visited.
But again – I nowhere find a solution for this… so I would like to ask you, if anyone have already this problem in the past and have a solution, I would very grateful for this.
Many thanks.
EDIT – Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem "rvm", "~> 1.9.2"
gem 'authlogic'
gem "rake", "0.8.7"
gem 'json'
gem "declarative_authorization", "~> 0.5.3"
gem "ancestry", "~> 1.2.4"
gem "taps", "~> 0.3.23"
gem "paperclip", "~> 2.4.5"
gem 'aws-s3'
gem "awesome_print", "~> 1.0.1"
gem 'actionmailer'
gem 'wkhtmltopdf-binary'
gem 'rails3-jquery-autocomplete'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5.rc.2'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
gem 'pg'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
EDIT2 – versions of used gems:
Using rake (0.8.7)
Using multi_json (1.0.4)
Using activesupport (3.1.2)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.2)
Using erubis (2.7.0)
Using rack (1.3.6)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.1.2)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.2)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.2)
Using activeresource (3.1.2)
Using ancestry (1.2.4)
Using authlogic (3.1.0)
Using awesome_print (1.0.2)
Using xml-simple (1.1.1)
Using aws-s3 (0.6.2)
Using bundler (1.0.21)
Using cocaine (0.2.1)
Using coffee-script-source (1.2.0)
Installing execjs (1.3.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.1.2)
Using coffee-rails (3.1.1)
Installing declarative_authorization (0.5.5)
Using jquery-rails (1.0.19)
Using mysql2 (0.3.11)
Using paperclip (2.4.5)
Using rails (3.1.2)
Using rails3-jquery-autocomplete (1.0.5)
Using rest-client (1.6.7)
Using rvm (1.9.2)
Using sass (3.1.12)
Using sass-rails (3.1.5)
Using sequel (3.20.0)
Using sinatra (1.0)
Using sqlite3 (1.3.5)
Using sqlite3-ruby (1.3.3)
Using taps (0.3.23)
Using uglifier (1.2.2)
Using wkhtmltopdf-binary (0.9.5.3)
So as I discovered, the problem is in dynos on Heroku. If you use Heroku as free, you have assigned 1 dyno. When nobody visit your page during a time (eg. 1 hour), so this dyno is idle -> that’s the reason of long time of loading the page.
If you buy the second dyno ($35 per month), so the dyno will be never idled and we will never meet the “slow loading” situation.