Possible to bypass Heroku's free plan's "Sleeps after 30 mins of inactivity" with console.logs?

Ralph David Abernathy picture Ralph David Abernathy · Apr 13, 2017 · Viewed 7.6k times · Source

Heroku has a free plan, as outlined here: https://www.heroku.com/pricing

One of the drawbacks of the free plan is that the server goes to sleep after 30 minutes of inactivity. Is it possible to bypass this if I have a console.log("stay awake"); occur every 20 minutes?

Thanks.

Answer

rsp picture rsp · Apr 13, 2017

It is not possible to bypass that limit - in a sense that all your services will likely get shut down before the end of the month for much longer than 30 minutes if you do that all the time - but you can keep your process alive e.g. by hitting some endpoint periodically but you will quickly exhaust your free hours that way:

Verified accounts come with a monthly pool of 1000 Free dyno hours; unverified accounts receive 550. When a Free dyno is active, it draws from the pool; your free apps can run as long as there are dyno hours left in your monthly pool.

It may be useful if you need to make sure that you API is responsive for short periods of time like during a demo or a presentation.

Whatever you do make sure that it is not against the TOC. When in doubt ask the customer service. They are very helpful.

If you want an uninterrupted service but Heroku is too expensive then you should probably use a VPS like Digital Ocean or Vultr. They are much cheaper, work 24/7 and you can have few months for free with promo links (Digital Ocean, Vultr) but the drawback is that you will have to make more things yourself - like install Node, deploy the application, keep the OS, Node and all services updated and configured properly etc. It's not that hard to do but you need to know what you're doing and no one will fix your system for you. To see how to install Node on a VPS see: