Why Your First Heroku Rails App Loads So Slow

If you are new to Ruby on Rails and you recently launched your first application on Heroku, you may be puzzled by how slowly your website loads at times.  Heroku has a built in power up/power down mechanism that automatically powers down your application if no one visits your website over a 5-15 minute period of time.  The application will stay down until someone visits the app again.  When someone visits the application, it will load, but it will typically take 20-30 seconds to power back up.  Not many users will stick around for this, but there is a trick most developers use to keep their Heroku app up all the time.  The trick is a side effect of using website monitoring tools

Website Monitoring Tools

There are tools like Uptime Robot and Pingdom that you can setup to make sure your website is available 24/7.  You should set these tools up to ping your website every five minutes.  The reason these websites exist is to monitor your website for outages.  Either you or your development team could accidentally bring your website down.  These tools check for website downtime and email you updates whenever the state of your website changes.  The awesome side effect of these services is that if the service is pinging your website every five minutes, Heroku doesn’t realize it is not a real human, so it never powers down your website.  Victory!

1 comment

Comments are closed.