DEV Community

Cover image for A Faster Free Heroku (Kinda) | Quick Hack
Nukala Suraj
Nukala Suraj

Posted on

A Faster Free Heroku (Kinda) | Quick Hack

If you've been building stuff on web for a while now, you've probably heard of HEROKU and NETLIFY

Just-In-Case you haven't heard about it

Quick Intro on Heroku and Netlify

  1. Heroku: A free PaaS (Platform as a Service), basically a cloud service that let's you host and share your web apps.
  2. Netlify: A free hosting service for static sites, basically react, vanilla javascript, etc projects.

NETLIFY is Usually Used on Frontend Projects.
HEROKU is Usually Used on Backend Projects.
Netlify + Heroku

The Problem with Heroku

Pro's:

  1. Heroku is Easy to Use.
  2. Heroku is Free.

Con's:

  1. Heroku has Premium

3 sec

Heroku's free tier uses dynos (Stuff That Hosts Your Code) that sleeps after 30 mins of inactivity

Once a dyno falls asleep, It takes time for it to awaken.
So the initial response is slow and the damage is already done.

Work Around

Re-Read This Line

Heroku's free tier uses dynos (Stuff That Hosts Your Code) that sleeps after 30 mins of inactivity

If You Haven't Got It Yet, Re-Read It Again

Heroku's free tier uses dynos (Stuff That Hosts Your Code) that sleeps after 30 mins of inactivity

💡Light Bulb💡

30 mins of inactivity

All We Need To Do is Do Something Every 30mins.
Nah 15mins to be on the safer side

For node.js dev(s) Out There

// Run Every 15 mins => 900 secs => 900000 ms
setInterval(()=>console.log("😂😜🤣🤓"),900000)
Enter fullscreen mode Exit fullscreen mode

GGWP,
@LucidMach

Top comments (11)

Collapse
 
aminnairi profile image
Amin

Your solution looks promising.

Although you didn't account for the pool of hours that your free-tier dyno has. This pool is limited to 550 hours per months. This seems big, but in fact it only represents a little more than 9 days. Largely before the end of the month though.

What this means is that by keeping the dyno constantly activated as you are suggesting, you will be running out of free dyno in 9 days.

If your application only has use for the first 9 days of each month this is a great solution though.

Worth noticing that you can increase this free-tier dyno pool by another 450 hours by adding a valid credit card. This will grant you a constant 16.5 days per month.

You better weight the pros and cons: sometimes, having a little more uptime is better than running out of free dyno and not having any uptime at all.

Just wanted to point that out but your technique is great for the other use-cases like a constant 9/16 days uptime per month.

Collapse
 
lucidmach profile image
Nukala Suraj

F, I didn't consider that 😅😅😅

Ig this article is pretty useless now
😂

Collapse
 
aminnairi profile image
Amin

You made a mistake, so what?

We all make mistakes. I do too. Don't let it be a failure but a recall that there might be more things to dig into when the solution looks too simple.

Even if your solution does not work (we all know that now), your though process was good, and you even documented your solution. This can be a calling to ethical hacking. Of course, there was more to it and the Heroku documentation prooved it.

Next time you'll learn from this mistake and dig into every piece of information you can find deeper and I'm pretty sure you'll find some interesting things to share to us here on DEV.

Thread Thread
 
lucidmach profile image
Nukala Suraj

😍
Yuppp, I'm never ever going to post about anything without testing it myself

No matter how amazing it looks

Collapse
 
king11 profile image
Lakshya Singh

I have seen several hacks for heroku and to me that looks like you are trying to exploit a free service which is very unethical.

Collapse
 
getdevved profile image
Get-DevVed-YT

I mean, it doesn't even work, because the dyno hours will run out after 9 days.

Collapse
 
king11 profile image
Lakshya Singh

yeah :P but makes sense not to just clear all dynos because maybe someday heroku people wake up and are like no we wont support the free tier anymore people just use all the dynos using such hacks....the end for several projects people try to make which utilize free tiers.

Collapse
 
lucidmach profile image
Nukala Suraj

Yea I just realised that too 😅

Sorry

Collapse
 
lucidmach profile image
Nukala Suraj

Yupp,
Turns Out This Wouldn't Work Anyways

Free Tier Dyno's has max active time of 9days per month

😅
Sorry

Collapse
 
lucidmach profile image
Nukala Suraj

Yupp,
Moreover It wouldn't work anyways
😅
I wasn't aware of it before writing this article

Collapse
 
yoursunny profile image
Junxiao Shi

I don't think a timer would prevent sleep.
These services are usually counted as active only if it receives HTTP requests.
UptimeRobot could keep it active though.