Finding your niche in the technology landscape is exciting and fulfilling at the same time. When your application or service is made available to customers, you feel that same thrill of completing some level of education, winning a game, or producing some artistic gem for others to enjoy.
But what happens when customers love your creation too much?
In the video link above, the product provided by Vertabiz became an instant success. At first, this was great! But seconds later, they realized they lacked the capacity to meet customer demand.
While the commercial in the link above was related to shipping and logistics, the same problem exists at the service level. Knowing when to scale up (and to scale down) to stay ahead of demand not only saves the customer experience but can yield financial rewards as well.
In this article, I am going to explore scaling options within the Heroku ecosystem.
In the Vertabiz video (above), the team realized a need to scale up their capacity when the number of orders exceeded their expectations. For a smooth customer experience with web applications, capacity should be added before existing services reach 100% utilization.
The concept of knowing "when to scale" is just as important as building a scalable architecture. After all, scaling up too quickly will consume more costs than required, and scaling up after the fact will impact performance and potentially lose customers. The same costly scenario exists when demand decreases, and there is no need to employ additional capacity.
Heroku provides the following options to help gain insight on knowing when capacity needs to change for your application or service:
Depending on the design of the application, it is possible to scale two different ways to meet consumer demand:
In most cases, simply adding instances horizontally does not fix the problem; that is, unless the application architecture is prepared for that scenario, as noted in the "processes" aspect of the Twelve-Factor App. This is where load balancers or API gateways are often introduced.
With Heroku, routing requests is part of the ecosystem — just another way Heroku saves time and resources. You can read more about this here:
The manual approach to auto-scaling with Heroku simply means someone will utilize the Heroku dashboard or the Heroku command-line interface (CLI) to address a demand-related need for a given application or service.
In the example above, if I wanted to increase the processing power of a Dyno configuration (scaling vertically) for one of my services running in Heroku, the following steps would be utilized:
If I wanted to scale my existing Heroku (Professional) application horizontally using the same user interface, the pencil icon in step number one would be selected. The ensuing screen would allow the number of Dynos to be increased as needed.
Using the CLI is another option to manually scale Heroku applications or services. However, this choice does rely on your knowledge of what the desired result will be.
As an example, to increase the number of Dyno instances, the following CLI can be executed:
heroku ps:scale web=3
To change the Dyno type, the following CLI can be executed:
heroku ps:type worker=standard-2x
Keep in mind that changes to the Dyno type do not alter the number of instances.
Of course, savvy DevOps engineers can use external processes to execute the Heroku CLI to automate Dyno scaling in Heroku by having a scheduled process execute CLI commands.
If you are running Heroku at the Performance-tier or have Dynos running in Private Spaces (dedicated environments running on an isolated network), autoscaling is built into the level of service provided by Heroku.
For those situations, the Resources tab in Heroku Desktop includes an Enable Autoscaling button, which introduces the following dialog:
Since this feature is limited to more advanced tiers of the Heroku ecosystem, the following link provides excellent documentation on this feature:
For applications running on other tiers in Heroku, there are several add-on products available in the Heroku Marketplace:
I have worked with a few of these add-ons, which are broken down into the following autoscaling categories:
In the scheduled mode of autoscaling, changes to the number of Dynos running in Heroku are known to the engineering team supporting the application or service. There are two subcategories of the approach:
The user interface subcategory contains Heroku Marketplace add-ons focused on setting schedules for applications or services running in Heroku. Those options include a purpose-driven user interface to make things easier for the end-user.
The following add-ons allow for Dynos to be autoscaled on a scheduled basis:
It is important to note that AutoIdle is a "scale down to zero" option only and is recommended for non-production environments. The primary goal is to save money for non-production Dynos that are not currently in use.
The scheduler-based add-ons can be employed to pass in CLI commands and can be used to scale up and down as needed.
This approach leverages the following Heroku CLI commands (noted in the Using Heroku CLI section above):
heroku ps:scale web=3 heroku ps:type worker=standard-2x
The following add-on products allow for CLI commands to be executed on a scheduled basis:
These solutions often lean on the basic Cron functionality running on underlying systems in the Heroku ecosystem.
The limitation of the Scheduled Autoscaling Mode is that the demand pattern for the application or service is fully known. Meaning, the higher and lower demand levels can be predicted. This may not always be known — the Vertabiz video in the introduction is an example scenario.
The smart mode of autoscaling alters the number of Dynos based on the current request/response time realized in your application or service. The following add-on products offer this functionality:
Using the Smart autoscaling option ensures unexpected changes in demand will be handled without any human intervention. This is helpful in those scenarios where demand exceeds any expected levels from the options noted in this document thus far.
In my publications, I have been referring to the following mission statement I proffer all IT professionals:
“Focus your time on delivering features/functionality which extends the value of your intellectual property. Leverage frameworks, products, and services for everything else.”
The need to leverage autoscaling solutions is a requirement when your application or service reaches the point where capacity needs to be scaled up and down to maintain positive consumer satisfaction levels. In my 30+ years in the IT industry, I have witnessed how wonderful solutions lose their appeal because of negative performance realities.
Currently, the following instance-count ranges exist for each Dyno type in Heroku:
While autoscaling incurs a cost, properly implemented levels will net overall savings from manual attempts at scaling your application or service. Using the options above, the probability of losing customers along the way is greatly reduced.
Have a really great day!