How To Scale Your Web Applications With Heroku

How To Scale Your Web Applications With Heroku

Building a web application is an exciting journey. This is even more so when users start signing up for your app in numbers. It doesn’t feel different from edging your opponents in competitive sports. After all, business is about competition, and nothing beats the thrill of success.

However, you may stumble into problems when the sign-up rate increases drastically. If you’re not prepared to handle the sudden increase in traffic, your customers will be left disappointed with the slow-loading application and degrading user experience. 

Despite its digital nature, a web application is not unlike a retail store that offers delivery services. Customers are bound to be frustrated when product shipments are delayed because the store cannot cope with the orders. 

Just like how the retail store would increase its logistic capacity, you’ll need to scale your web application to handle traffic growth. Doing so offers various benefits, such as improving customer satisfaction and revenue.

This article will show you how to scale your web apps with Heroku easily. 

What is the best time to scale?

Generally, you’ll need to scale the app’s resources before hitting the maximum limit. With that said, it is helpful to learn the exact condition before you need to start scaling. This is important because scaling too fast leads to costly expenses while missing out on the right timing leads to performance degradation and unhappy customers.

Also, you’ll want to maintain the flexibility of scaling down the resources. If your demands in your app suffer a dip, scaling down allows you to prevent costly expenditure. Thankfully, Heroku will enable you to scale the Dynos in both directions according to your needs.

Here’s how to check your web application’s capacity on Heroku.

  • Use the Metrics tab on the Heroku dashboard to view a visualized chart of historical demands and the current capacity of your app.

  • Install the loader.io add-on, which helps to determine if your application requires additional capacity.

  • Monitor your app’s performance with the Monitor add-on from Heroku marketplace.

Your app can be scaled in a couple of ways to meet the increasing demands.

  • Horizontal scaling - Add more instances of the same Dyno.

  • Vertical scaling - Upgrade the current Dyno to one with more computing resources.

You’ll also want to consider request routing. It is an alternative to increase resource efficiency on Heroku. 

How to scale manually with Heroku

There are two ways to scale with Heroku manually. You can either use the Heroku dashboard or the Command Line Interface (CLI) to allocate additional resources to your app. 

Heroku web dashboard

Here’s how to vertically scale Dyno’s computing power for an app or service running on Heroku. 

1. Access the Heroku dashboard and navigate to the Resource tab.

null

null

2. Complete and save the settings as per the instruction. Heroku will power your app with the new Dyno requirements.

It is also possible to scale horizontally with Heroku. To do so, select the pencil icon on the Resources tab. You’ll find an option to change the numbers of Dynos. Then, choose the numbers of Dynos required.

Heroku CLI

The Heroku CLI is an alternative to scale your applications or services manually. However, you’ll need to have a technical understanding of Heroku to use the CLI properly. 

For example, you’ll need to insert the following commands into the CLI to increase the number of Dynos. 

heroku ps:scale web=3

heroku ps:type worker=standard-2x

DevOps teams can also access the CLI with external processes. For example, they can run CLI commands with a scheduled process that connects to the CLI. 

How to automatically scale with Heroku

You’ll have access to auto-scaling capability when you are using the performance tiers of Heroku or have Dynos running on private spaces. 

When you open the Resources tab on the Heroku dashboard, you’ll find an autoscaling button. Clicking on the button leads to the following dialog. 

null

Autoscaling is considered an advanced Heroku ecosystem feature. You’ll find extensive documentation on this subject from Heroku. 

Other autoscaling alternatives

If you run apps on tiers that doesn’t support autoscaling, you can turn to the Heroku marketplace for alternatives.

null

Most of these autoscaling add-ons can be categorized as follow:

  • Scheduled mode - automatically scale the resources according to a schedule.

  • Smart mode - automatically scale when triggered by a request or response.

With the scheduled mode, the development team sets the new Dynos number in the autoscaling add-ons. The add-ons can be categorized as follow:

  • User interface - The add-on features an exclusive Dyno-scaling interface.

  • Scheduler - The add-on allows scheduling via the CLI. 

UI-based add-ons allow developers to create schedules for web apps and services on Heroku. These add-ons empower user experience with a purposeful user interface. 

Here are some add-ons that allow you to schedule automatic scaling of Dynos:

  • AutoIdle

  • FlightFormation

Scheduler

Developers use scheduler-based add ons to run CLI commands. You can also use the add-ons to scale the Dynos up or down as required. 

These are examples of schedule-based add-ons.

  • Cron To Go Scheduler

  • Heroku Scheduler

  • Process scheduler

Intelligent autoscaling mode

The above-mentioned auto-scaling feature has its limit. It requires developers to know the exact demand of an existing application. In actual applications, traffic patterns can be hard to predict, resulting in difficulties setting the correct autoscale parameters. 

With the intelligent autoscaling mode, you can atomically change the number of Dynos based on your app's real-time traffic or resource consumption. These are add-ons that support intelligent autoscaling.

  • Adept's Scales

  • Rails Autoscale (for Ruby only)

Conclusion

Autoscaling is a necessary feature to scale your application up or down to keep your customers happy. Failing to realize its importance often leads to subpar performance. While you need to pay more for Heroku’s autoscaling feature, the additional cost translates into savings when you don’t have to scale the Dynos manually. 

Use Heroku's autoscale to provide the necessary computing resources and keep your customers happy. 

Get my newsletter

Heroku stories, lessons, and tips.