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

1

6

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?

Piccoloist answered 13/4, 2017 at 13:37 Comment(0)
E
9

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:

Extrapolate answered 13/4, 2017 at 13:40 Comment(5)
Kinda contradicted yourself. It is not possible to bypass that limit. You can keep your process alive although I gave you a +1 for the warning about running out of the dyno hoursUnderplot
@Underplot I meant that 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. I may not have been clear enough. Thanks for pointing it out. :)Extrapolate
It's worth noting that VPS services like DigitalOcean (good though they are; my site is hosted on there and the service has been excellent thus far) are a fair bit more hands-on than Heroku - expect to do quite a bit of Linux command-line stuff if you opt for that option. That's why Heroku costs more - you're paying for the convenience of not having to manage that side of things yourself.Offence
Thanks for the answer and comments. I'm fine with setting up the server up myself. Just looking for a free a server to house a Slack bot that sends 1 message every week.Piccoloist
@RalphDavidAbernathy If your server needs to send 1 message every week then I don't think that having few seconds of waking up after 30 minutes inactivity should be a concern here.Extrapolate

© 2022 - 2024 — McMap. All rights reserved.