Skip to Main
Home

Control Heroku infrastructure cost with auto scaling

Heroku Cost Reduction

At Showoff, we know a thing or two about leveraging Heroku to build engaging solutions for our clients and their customers. Many of our clients use Heroku for its ease of use, scalability, and security—but like any other managed service—costs can add up, especially when you factor in non-production environments.

Recently, we implemented a number of changes to how we handle these environments, including automatically scaling dyno-formations based on work hours. Here’s how we did it and how it helps our clients save significantly on their infrastructure costs without impacting delivery.

The problem: High costs for lower-level environments

Our clients have various lower-level environments (such as staging, development, and testing) hosted on Heroku. Unlike production, these environments aren’t in constant use, and they’re typically accessed only during regular business hours. Running these environments 24/7 wasn’t an efficient use of resources, especially when the team only needed them during the day. However, scaling them manually wasn’t practical either, given the potential for human error and the added maintenance load.

The solution: Automated scaling with Heroku Scheduler and CLI

To tackle this problem, we developed an automated approach using Heroku Scheduler combined with Heroku CLI to scale up and down at set times. This allowed us to set up a schedule that automatically reduces infrastructure costs for lower-level environments without requiring any manual intervention.

Here’s a breakdown of the solution:

Setting up Heroku Scheduler

Heroku Scheduler is a tool that allows tasks to be run at scheduled times. We used it to execute commands at specific intervals.Using the scheduler, we set up tasks to scale down non-production environments at the end of each workday and scale them back up before the start of the next workday.

Using Heroku CLI for scaling

With the Heroku CLI, we wrote commands to adjust the dyno counts (or process units) for each environment. At the end of each day, we use the CLI to scale down non-production dynos to a minimum configuration. Then, at the start of the next workday, we run another CLI command to scale these dynos back up.This approach effectively brings down the cost of maintaining these environments outside of working hours.

Maintaining production stability

Production environments, as a rule, cannot be scaled down. This is essential to ensure high availability and reliable service for end users.Our automation is configured to ignore production environments entirely, focusing solely on lower-level instances.

Results: Significant cost savings

This automated approach has yielded substantial cost savings for our clients. By scaling down non-production environments during off-hours, clients avoid paying for resources that aren’t in use. Here’s an example of the impact:
For a typical staging or testing environment, this automation can reduce operating costs by up to 70%.
This approach has also freed up engineering time since they no longer need to remember to manually scale environments up or down.

Key takeaways

Our Heroku cost-saving strategy underscores a few principles that can be broadly applied to any infrastructure:

  • Identify non-critical environments: Scale down environments that don’t need constant availability.
  • Leverage automation tools: Use tools like Heroku Scheduler to automate scaling based on predictable schedules.
  • Avoid production downtime: Ensure that production environments are left out of any cost-saving automations to maintain availability and performance.

At Showoff, we’re thrilled to see how this automation is making a real difference for our clients. This combination of Heroku’s powerful tools and a bit of creative scheduling has allowed us to reduce infrastructure costs without sacrificing the convenience of cloud-based lower-level environments. And best of all, it’s a set-it-and-forget-it solution that keeps saving money month after month!

Ready to optimize your infrastructure costs? Get in touch to see how Showoff can help you leverage automation to make your infrastructure more efficient and cost-effective.

__________

By Philip Kirwan, CTO @ Showoff and John Kilbride, Chief Architect @ Showoff

May we use cookies to track your activities? We take your privacy very seriously. Please see our privacy policy for details and any questions.Yes No