Why are my basic Heroku apps taking two seconds to load?
- If your application is unused for a while it gets unloaded (from the server memory).
- On the first hit it gets loaded and stays loaded until some time passes without anyone accessing it.
This is done to save server resources. If no one uses your app why keep resources busy and not let someone who really needs use them ?
If your app has a lot of continous traffic it will never be unloaded.
There is an official note about this.
5 seconds of not loading, heroku node.js app slow loading
This particular app was bundled with the angular cli (probably using webpack under the hood). I found that building using command ng build --prod
would bundle the files much tighter and this eliminated the load time.
Heroku website only loads slowly the first time, even after clearing local cache?
Quoting the Heroku docs:
If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep.
When the dyno receives traffic again, it will take a few seconds to wake up, hence the delay you've experienced.
Note that the Heroku free tier also has a maximum number of dyno hours per month. A sleeping dyno doesn't use any hours, but it does when it's active. When the hours are used up, the dyno won't wake up to incoming traffic.
You can see your remaining quota of dyno hours with:
$ heroku ps -a <app name>
Heroku suggests upgrading to a hobby dyno if your app needs to be permanently accessible. More info on https://devcenter.heroku.com/articles/free-dyno-hours
Related Topics
How to Identify Aliased Methods in Ruby
Difference Between Downcase and Downcase! in Ruby
Rails Active Admin CSS Conflicting with Twitter Bootstrap CSS
Railstutorial - Chapter 8.4.3 - Test Database Not Clearing After Adding User in Integration Test
Finding If a Sentence Contains a Specific Phrase in Ruby
Check If an Array Is Subset of Another Array in Ruby
Is Everything an Object in Ruby
Sinatra Clears Session on Post
Why Is Gets Throwing an Error When Arguments Are Passed to My Ruby Script
What Is Recursion and How Does It Work
How to Write a Ruby Switch Statement (Case...When) with Regex and Backreferences