1

Heroku reboots servers everyday. After reboot, my node server takes around 20 seconds to load a page for the first time. Is there a way to prevent this?

EDIT: You guys seem to be misunderstanding the situation. In Heroku, even production servers must be restarted daily. This is not the same as a free server sleeping. This question is aimed more at preventing lazy-loading and pre-establishing connection pools to databases.

  • Are you using the free tier? Free tier I believes sleeps after 30 minutes of inactivity. If you need higher availability I would suggest paying for the hobby plan. – user2263572 Aug 29 '17 at 23:52
  • Possible duplicate of [Avoid heroku server from sleeping](https://stackoverflow.com/questions/40646858/avoid-heroku-server-from-sleeping) – TGrif Aug 30 '17 at 09:52
  • @NeedHelp it may be a different reason but the solution is the same: hit it with a request. – Paul Aug 30 '17 at 23:49

1 Answers1

1

Old question, but in case others stumble upon it like I did

Use can use Heroku's Preboot feature:

Preboot changes the standard dyno start behavior for web dynos. Instead of stopping the existing set of web dynos before starting the new ones, preboot ensures that the new web dynos are started (and receive traffic) before the existing ones are terminated. This can contribute to zero downtime deployments

You could also combine it with a warmup script like the one described in this Heroku post

dstj
  • 4,800
  • 2
  • 39
  • 61