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

邮差的信 提交于 2019-12-07 07:48:06

问题


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.


回答1:


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?


来源:https://stackoverflow.com/questions/43393815/possible-to-bypass-herokus-free-plans-sleeps-after-30-mins-of-inactivity-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!