o9s
is a microblog
home archives search feed blogroll


The Ghetto Way To Keep Your Heroku App Awake

Heroku apps in the free tier go to sleep every 30 minutes. This means that if your app has not been accessed for a while, it will need some time to start up.

There’s a few ways to prevent this. The easiest is to use a service like Kaffeine. It will ping your site every 30 minutes. You can also use the Node script below to do the same.

var http = require("http");
setInterval(() => {
    http.get("http://[your_app_name].herokuapp.com");
}, 30 * 60 * 1000);

Since August 15, 2015, all free apps are required to sleep at least 6 hours every day. You can set a bedtime on Kaffeine. If your app does not sleep enough in a given month, it will be required to sleep for the rest of the month. Be careful with the above script.

Posted on 2018-01-28   #heroku     #javascript     #node  






← Next post    ·    Previous post →