Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does a Heroku-hosted application take so long to start up?

I recently created my first Heroku application and I'm finding some strange behavior:

When the application hasn't been accessed in a while, I think the server shuts down. Then, if you access it, it takes about 20 seconds to start up before it responds. After this initial start up phase, it responds quickly.

Is there a way to avoid this "start up / shut down" phase?

like image 708
Geoff Avatar asked Aug 01 '11 04:08

Geoff


People also ask

Why does Heroku app take so long to load?

To preserve your dyno hours from burning out or wasting, Heroku puts your app to sleep after 30 minutes of inactivity. How generous! This is what makes your app is slow to load. When your app's dyno is asleep, waking it up may take some time.

How long does it take for Heroku to wake up?

This means if your application has not served any requests for one hour, it is forced to sleep by heroku and has to wake up prior to serve a new request, which easily can take up to 30–40 seconds.

How long does Heroku app take to go to sleep?

As you may have known that Heroku does not allow your app to run for more than 1 hour. When an app on Heroku has only one web dyno and that dyno doesn't receive any traffic in 1 hour, the dyno goes to sleep. When someone accesses the app, the dyno manager automatically wakes up the web dyno to run the web process type.


1 Answers

Yes, pay for a full-time dyno. The Heroku docs state that when you're on the free tier if your dyno is not in use for a while (30 minutes in my experience) it shuts down. It restarts the next time it receives a request.

See: http://devcenter.heroku.com/articles/dynos#frequently-asked-questions

Heroku refers to his as "Dyno Idling."

like image 148
Andrew Avatar answered Oct 05 '22 11:10

Andrew