Steven Brooks' Blog

Student @Flatiron School

15 Second Heroku Wait?

Here is the scenario you are in. You built a Rails app. Congrats. You have also pushed you app to Heroku. Even better. But after every hour, your Heroku server is seemingly shut down; that’s why it can be free because it’s not always “in use”.

There’s an easy way to combat that for free.

1) Make a rake task that will “ping” your site.

(update.rb) download
1
2
3
4
5
6
7
8
desc "Pings PING_URL to keep a dyno alive"
task :dyno_ping do
  require "net/http"


    uri = URI("YOUR SITE")
    response = Net::HTTP.get_response(uri)
end

2) Install Heroku Scheduler and set have it run the rake task every hour.

That’s it. Now every time you go to your site you won’t have to wait 15 second for it to load.