Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 938
Ralph David Abernathy Avatar asked Apr 13 '17 13:04

Ralph David Abernathy


1 Answers

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:

  • NodeJS API with external deps in other language
  • Run npm as superuser, it isn't a good idea?
  • NPM and NODE command not found when using NVM
  • How to host website in NodeJS and MongoDB? And what will be the cost?
  • Simple node.js app deployment on DigitalOcean from GitHub
  • Install Node.js with downloaded binary on Ubuntu Desktop.. Where do the files go?
like image 74
rsp Avatar answered Sep 22 '22 10:09

rsp