Tips for running free dynos on Heroku in 2020
Heroku has changed how they handle free dynos multiple times over the years, so you'd be excused for being a little lost about the current state of things. The bottom line is that while it's possible to run a 24/7 production app on a free Heroku dyno, it comes with some caveats. In this article we'll dive into the details and clear up the confusion.
The current official docs do a fine job laying out the basics:
Accounts are given a base of 550 free dyno hours each month. In addition to these base hours, accounts which verify with a credit card will receive an additional 450 hours added to the monthly free dyno quota. This means you can receive a total of 1000 free dyno hours per month, if you verify your account with a credit card.
A few points of clarification I'd add:
- Free dynos are not available for Heroku Teams.
- In 2015-2016 there was a time when free dynos could only run 18 hours a day, but this is no longer the case.
- If you had a free app running when these new rules launched in 2016, you may have been grandfathered in and have more than 1000 free dyno hours available to you. Lucky you!
You can check how many free dyno hours you have available at any time on your Heroku billing page.
That's nice to know, but let's unpack what "free dyno hours" means. Free dynos are one of Heroku's six dyno types.
Free dynos are identical to hobby dynos ($7/mo) and standard-1x dynos (\$25/mo), with some limitations:
- Heroku's SSL for custom domains is only available on paid plans. I use Cloudflare's free SSL, which makes this a non-issue. It's also a non-issue if you want to use the default *.herokuapp.com domain, which always supports SSL.
- Heroku's metrics tab is only available on paid plans. Check out Librato's free add-on for similar metrics.
- Free (and hobby) dynos can't be scaled up to multiple dynos. You can only run a single dyno of each type (web, worker, etc.). If you've outgrown a single dyno, though, you're hopefully making some revenue and can start investing in your hosting.
- Free web dynos will "idle" (temporarily shut down) after 30 minutes of inactivity. This is good for not using all of your free dynos hours, but obviously a bad thing if you want your site running 24/7. The fix for this is pinging your app with an uptime monitoring tool. Freshping is a good free option.
This means you can run the equivalent of a standard dyno for free for 1,000 hours per month. With 744 hours in a 31-day month, that means you can run your production app 24/7 on Heroku for free, right?
Well, that depends.
Most production apps need at least a web process and a background worker process for things like sending email and processing payments. That's two dynos running for 744 hours per month, which exceeds your 1,000 hour allotment. Free worker dynos do not automatically idle like free web dynos do, so they'll be running 24/7 unless you manually scale them down.
This is where you need to decide just how "production-scale" your app needs to be right now. You could perform this work synchronously within your web process instead of backgrounding it, or you find a way to run async jobs within your web process. Some background work could also be performed on a periodic basis with Heroku Scheduler, which only uses dyno hours for the time it's running.
If you really do need a separate worker process (many production apps do), then you've probably outgrown free dynos.
We also need to talk about your database. Heroku's free Postgres offering is limited to 10,000 records. Yeah... that hurts.
Even the smallest production apps are likely going to exceed this limitation. Here are your options:
- Upgrade to a paid Heroku database plan, starting at \$9/month for 10,000,000 records.
- Use a third-party hosted database provider with a more generous free plan, like ElephantSQL.
I personally think Heroku's Postgres plans are worth every penny, but I also know firsthand the cost can be hard to swallow when launching a side project with no revenue.
So with all this in mind, when do Heroku's free offerings make sense for you?
- Launching a side project. There's a good chance the side project won't get much traction, so throw it on free dynos and a free Postgres DB and see what happens! You won't have enough free hours to run worker dynos, but who cares... until you have real users, you can do everything in your web process.
- Running a staging or QA app. These are perfect for free dynos because they don't need to run all the time. Your staging data might even fit within a free Postgres DB.
Beyond those use cases, you're probably going to have to pay for Heroku. The free options exist to try out the service, play with an idea, and run experiments. Once you're running a "real app", you should be at a point where you can spend a few dollars on hosting. You'll still be spending a whole lot less than the engineering time required to manage your own production environment.
February 5, 2019
Last updated on April 5, 2020