Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I build MVP's for clients regularly. Often I deploy on Heroku so they can see if the product works and demo it to prospects and investors.

Then I have an application deployed on heroku, and it works like a charm, if not for one little thing. The app takes about 30 seconds to start up and heroku has the annoying habit of killing dyno's if they don't get traffic. My client is using the application for demo purposes now, so the load is extremely low and intermittent.

I'm looking for a solution that is preferably:

  • cost effective
  • can be applied to multiple apps simultaneously

What is the best way to avoid having the first request taking 30 seconds?

share|improve this question
    
Re: your attempted edit to my answer, no, Pingdom has a free level of service. –  ceejayoz Nov 4 '12 at 15:19
    
@ceejayoz ah, I must have missed that on their site they say 1 site 20 sms's is free... which is well, nice and all, but it's "free level of service" for varying values of free I guess. I'm not one to flame a freebee, but it's no more than that. –  iwein Nov 4 '12 at 22:14
    
Based on your question, you only need the one site, and you don't really need the SMSes at all. –  ceejayoz Nov 4 '12 at 22:42
    
@ceejayoz, you're right, but I thought I could make your answer more complete by mentioning other options than Pingdom. Nothing against the solution, but for my particular use case (which wasn't very clear in the question) it doesn't fly. I tried to reconstruct my edit (minus the error) and put it in my own answer. You can comment there or suggest edits if you still see a problem with the wording. –  iwein Nov 5 '12 at 5:51

7 Answers 7

up vote 5 down vote accepted

Heroku now has a cron-equivalent add-on called Scheduler. Based on a tutorial:

  1. In app/lib/tasks, add a file named scheduler.rake with this task defined:

    desc "This task is called by the Heroku cron add-on"
    task :call_page => :environment do
       uri = URI.parse('http://www.myapp.org/')
       Net::HTTP.get(uri)
    end
    
  2. Add the "Scheduler" addon from your Heroku control panel or from the console:

    heroku addons:add scheduler:standard

  3. Configure Scheduler to run this task hourly.

    heroku addons:open scheduler

I suspect this is Heroku's preferred method, as a Heroku community rep demonstrated this technique at a talk.

share|improve this answer

You can point a Pingdom check at your site's URL. As a bonus, you'll be keeping an eye on downtime while you do so.

share|improve this answer
    
Awesome! I'm looking at it right now :) Thanks. –  Ragunath Jawahar yesterday

Simple answer: You pay for it.

Ramp up to two dynos and your app will not idle.

If cost conscious then only ramp up to two web dynos for short periods of time around your client's demos. Heroku only charge $0.05 per hour.

Or drive frequent traffic to the app somehow so it does not idle. But Heroku offer such a great service that you use for free so why not throw them a few cents for the periods you need guaranteed response.

share|improve this answer
    
You're right of course, but with a lot of startups and a lot of apps for my clients this adds up (either mental overhead of scaling all those apps up and down, or in costs per month). The $35/m for two dynos doesn't do right by my usage pattern. I've found a nice hack btw: iweinfuld.posterous.com/… –  iwein Nov 2 '12 at 6:10

Using the New Relic monitoring service seems to be a good option...

How to in the following post:

Avoid Heroku idling with New Relic pings

share|improve this answer

Have your Heroku-hosted site indexed by Google (and other major search engines).

A Heroku app I uploaded a few months ago for internal use, but which has to be accessible to clients, has somehow been found by Google and the (very small) public section of the site indexed. Nevertheless, a few months after first putting it up, Google is making about one request every 70 seconds, more than enough to keep the dyno active continuously.

share|improve this answer
    
That's strange, but it is a solution if you're that lucky :) –  iwein Jan 11 '13 at 20:21

It's in the FAQ, at the end, "What is dyno idling?"

https://devcenter.heroku.com/articles/dynos

Apps that have more than 1 web dyno are never idled out. Workers dynos are never idled out.

Basically, this happens on the free tier. If you start up a second dyno (i.e., pay $35/month), the dynos will not idle.

If it's the case where your client is doing a presentation, i.e., a scheduled look at the application during a meeting, the idling doesn't occur until after an hour of inactivity. If he doesn't feel like paying $35/month in this scenario, he can poke the application before the meeting to wake it up.

share|improve this answer

There are two options:

  1. Pay for it

    As soon as you heroku scale web= above 1 the app will never iddle out, as cjk and flurdy also mention in their answer. This is by far the best option if you have a single site that is paying its own bills. If you're maintaining many sites, the costs add up though.

  2. Periodically ping the service

    This option is the interesting one. For low trafic sites there is no free solution I could find. Pingdom (as mentioned by ceejayoz) is free for one site, so that would solve the problem once. If you need more sites, you can also use Iron.io to keep your heroku dynos alive. This will also quickly run out of the free tier though and then you'll be paying Iron.io.

    If you are lucky enough to have a server running already, you can stick a curl to your site in the crontab. This solution scales best of course.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.