An Interest In:
Web News this Week
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
Your Heroku App Is Slow to Load Because Of This.
No doubt that Heroku is a great tool for developers. One particular reason for me is its generosity. I will explain how
Heroku Dynos
If you're already using Heroku, then you should be familiar with dynos. A dyno is a lightweight, isolated, Linux container. It is basically how Heroku runs your app.
With a free plan, you can get 550 hours of dyno per month with an unverified account and 1000 hours of dyno with a verified account. (Your account gets verified when you submit your card details. See more details here.)
What this means is, for each month, your app can only run for 1000 hours (verified account) or 550 hours (unverified account).
To preserve your dyno hours from burning out or wasting, Heroku puts your app to sleep after 30 minutes of inactivity. How generous!
This is what makes your app is slow to load. When your app's dyno is asleep, waking it up may take some time. But after the first load, it starts loading pretty fast because the dyno is active.
How do we solve this?
If you don't want your app to go to sleep no matter the inactivity, then I have solutions for you. There are 744 hours in 31 days, so having a verified account keeps you ahead.
Before we look at the solutions, let's see why you may need your app to always be on:
Let's say you have a portfolio, as a full-stack, you wouldn't want a potential client to wait that long for your dyno to wake up.
The worst part is when you're using a custom domain and not a Heroku subdomain (yourapp.herokuapp.com). With the subdomain, He/She may consider knowing fully well your dyno is waking up. But with a custom domain ... you will have to explain yourself then.
Another scenario for you to keep your app alive is with Discord Bot or Twitter Bot. You'd want these bots to always be active at any time right?
What you need is someone to keep your app active so your dyno won't go to bed. You need someone to always reload your app every 5 minutes or 10 or 20 but not 30 above.
That someone is Uptime robot. Uptime robot will keep your app active and also looks out for downtime (when your app stops working). I will show you how to monitor and keep your app active with Uptime robot.
Visit www.uptimerobot.com. Register an account. You will be redirected to your dashboard.
- Click the
+ Monitor
button - In the monitor type field select HTTP(s)
- Fill the other fields with a name for your app, the URL of the app.
- Set an interval, the minimum is 5 minutes.
- Select the contact you would want them to notify for any downtime. It's optional.
- Lastly click the green
Create Monitor
button.
Soon as you are redirected to your dashboard, you will see that app you're monitoring in your dashboard. Click on the name of the app to see more stats of the app.
Another option is to upgrade your Heroku plan from a free tier to a paid plan, here is Heroku pricing.
Summary
I almost wanted to switch from Heroku because of this issue. I used mine for an API and a discord bot. But this solution solved my problem.
I have a Discord server for web developers to help with their coding journeys. See Info here.
If you like this post and want to support me you can buy me a Coffee.
Thank you for reading.
You might be interested in
Original Link: https://dev.to/elijahtrillionz/your-heroku-app-is-slow-to-load-because-of-this-4lep
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To