If you're thinking about launching new applications this year, there are many good reasons to choose Heroku as your hosting platform. In addition to its ability to make deployment and environment configuration easy, Heroku provides a well-designed platform, tools, documentation, and an extensive add-on community.
Heroku's superpower is managing your servers for you. It hides the intricacies of server maintenance and provides a friendly interface to manage your application. Deploying is easy once you're up and running. You can focus on your code without worrying about managing infrastructure.
As a developer, I personally enjoy the ready-to-use environment Heroku provides. You can create a new server in seconds using the Command Line interface. Heroku is flexible and friendly towards beginners in the way it allows you to integrate with familiar developer workflows.
The opportunity cost of using Heroku, however, is the amount of money you'll have to spend as your application grows–you'll need more dynos (servers) and third-party add-ons to handle demands from users and your growing application.
Knowing how to optimize your use of dynos, when to autoscale, or put an application to sleep will help you save significant costs on app development. In this article, I'll share three money-saving tools top Heroku developers use to cut costs
Save money before production
Typically, alpha and beta releases help developers launch their applications, catch errors, and receive useful feedback from early adopters.
Review apps on Heroku work like alpha and beta releases on steroids. They are disposable applications that enable developers to build and test app environments on a temporary URL before merging changes back to production. Review apps also help to improve code review and acceptance test workflows.
However, before you commit to using review apps, it is important to know that every second your application runs on Heroku increases your server costs. If your applications run 24/7, you'll rack up high costs over time.
The good news is that you don't need your apps running every second of the day. You can save money by putting your applications to sleep when you don't need them. The best tool to help you achieve this is AutoIdle.
This may come across as a humblebrag, but I wouldn't suggest AutoIdle if it weren't one of the most recommended Heroku add-ons for saving server costs on Heroku. As of January 2022, over 300 organizations worldwide have saved over $500,000 using AutoIdle.
AutoIdle is a Heroku add-on that saves you money by automatically putting your applications to sleep when they've been inactive for about 30 minutes. It is designed for staging and review applications, but it also works for non-critical applications running in other servers' backgrounds.
A great feature of AutoIdle is its ability to start your application without displaying an error message on the first request, and it does this with a minimal lag. It integrates easily into your Heroku application in a few clicks and works as a set-and-forget type of application. Once activated, you don't have to do anything else.
Try out the calculator of AutoIdle:
Save money at production stage
You start to feel the heat of dyno costs when you get to the production stage. You will need to add more dynos to handle the spike in activities as your application grows. Heroku makes it easy to choose how many dynos you need using their autoscale feature.
However, autoscaling is available only for performance-tier dynos and dynos running in private spaces. The free and hobby dynos do not have autoscale. Luckily, there are third-party add-ons that can help you autoscale lower-tier applications. My top two picks are Rails Autoscale and Adept Scale.
If you're on a lower tier on Heroku, you'll need to use an add-on like Rails Autoscale. It works based on request queue time, not total response time, making it faster than Heroku's native autoscaling solution. However, as the name suggests, you must be running a Rack-based Ruby app on Heroku to use this add-on. Rails Autoscale also supports scheduling tools like Sidekiq, Resque, Delayed Job, and Que.
You can split your worker queues across multiple processes and configure each one independently. Rails Autoscale works seamlessly on standard and performance dynos, helping you save more money the more dynos you use.
3. Adept Scale
You know those tools that make your work so easy you can spend time working on projects you love while sipping coladas at the beach? Adept Scale is one of those. With its easy-to-use scaling settings, it protects your applications from shutting down when traffic increases suddenly.
Integrating Adept Scale in your applications reduces the number of running web dynos during low-traffic periods. An important point to note is that Adept Scale requires adequate time after initial setup to gather data insights from your application usage to develop the best settings for your needs.
Once the application has a good working set of data it goes to work. You can then adjust the configurations to dictate how the scaling responds based on the usage patterns of your app.
Launching applications and seeing users experience them is the highlight of most developers' careers. However, the costs involved in building and scaling these applications can take the joy out of watching your baby grow.
This is why I have suggested these tools to help you scale down your applications when they are not in use. When your applications are scaled down, you will not be billed for them.
Are you ready to build and launch that application this year? Make sure to use one of these three money-saving tools to save costs on Heroku. You can find more here as well.