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
- Heroku: A free PaaS (Platform as a Service), basically a cloud service that let's you host and share your web apps.
- 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.
The Problem with Heroku
Pro's:
- Heroku is Easy to Use.
- Heroku is Free.
Con's:
- Heroku has Premium
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)
GGWP,
@LucidMach
โ
Top comments (11)
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.
F, I didn't consider that ๐ ๐ ๐
Ig this article is pretty useless now
๐
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.
๐
Yuppp, I'm never ever going to post about anything without testing it myself
No matter how amazing it looks
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.
I mean, it doesn't even work, because the dyno hours will run out after 9 days.
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.
Yea I just realised that too ๐
Sorry
Yupp,
Turns Out This Wouldn't Work Anyways
Free Tier Dyno's has max active time of 9days per month
๐
Sorry
Yupp,
Moreover It wouldn't work anyways
๐
I wasn't aware of it before writing this article
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.