If you’re running applications in the cloud, you have the ability to use and pay only for resources that are needed to process the current workload with auto-scaling.
In many cases, to optimize the usage of compute resources such as Azure Cloud Services (worker roles), Azure WebApps running WebJobs, or Azure Virtual Machine Scale Sets (VMSS), it is beneficial to adjust the number of instances according to demand.
In this article, we’ll show you how to automatically scale Azure compute resources based on queue-based workload using Netreo. If you are not familiar with Netreo, it is a cloud monitoring service that provides a set of sophisticated automation and monitoring capabilities for the Azure platform.
A popular way to distribute workloads among multiple compute instances is by using Azure Service Bus queues or topics. Coincidentally, observing the number of messages in the queues/topics provides useful signals for auto-scaling of compute resources.
When the number of messages in queues/topics exceeds a certain threshold, it is a good indication that services processing those messages are having trouble keeping up. Consistently, a few messages in queues/topics indicates that the number of compute instances can be scaled down to reduce costs.
To auto-scale compute resources such as Azure Cloud Services, WebApps running WebJobs or VM Scale Sets, based on the number of messages in Azure Service Bus (ASB) queues/topics or Azure Storage queues, you need to follow these four simple steps:
1. Run Netreo Setup Wizard to start monitoring ASB/Storage and Azure Compute resources
If you aren’t using Netreo yet, request a demo, and our team can help run you through the process.
2. Define a queue length metric
Once ASB/ASQ resource has been brought into Netreo, define a new metric that tracks the length of a particular queue or topic:
3. Link the queue length metric into the Compute resource
To define auto-scaling rules for compute resource (VMSSs, WebApps, or Cloud Roles), you need to have those resources “see” the newly defined queue length metric:
4. Define auto-scaling rules
Compute resource will need to have two rules to increase and decrease the number of workers based on the metric value. It is also a good idea to define limits to ensure the number of instances doesn’t exceed expected values:
Netreo supports many sophisticated auto-scaling scenarios. Request a Demo and Learn more here.
The same approach can be used to auto-scale other Azure resources, such as Cloud Services or VM Scale Sets. Netreo can auto-scale resources based on any metric captured anywhere in your Azure environment, or according to a schedule.