Autoscale azure virtual machine scale set


In our previous video, we discussed how to create a virtual machine scale set. In this video we will discuss the scaling options we have i.e how to increase or decrease VM instances in a scale set.

Why increase or decrease VMs in a scale set

Well, there are a number of reasons. 

One reason could be, most of your customers use your application during specific times of a day. May be 10:00 AM to 12:00 noon and then again from 3:00 PM to 5:00 PM for example. During these 2 windows, you want your application to be fast and performant. So you may want to increase the number of VM instances that run your application. Outside of these 2 windwows, your application does not have that much demand. So, to save on cost you want to reduce the number of VMs that run your application.

Another reason could be, next week, you are launching a new product or a business line. So starting next week, you are going to have a heavy peak may be for 3 days. So during the heavy peak season, you want more VMs to run your application. Once the peak subsides, again to save on cost, you want to fall back to your baseline configuration.

Another reason could be, you are in a situation, where you cannot predict the demand for your application. So you don't really know, when you need more procesing power and when you can fall back to that baseline configuration. Well, for this we can use metric based auto-scaling.

Virtual machine scale set scaling options

In Azure, there are 3 options for scaling VM instances up and down. 

  1. Manually through the Azure portal
  2. Auto scale based on metrics or 
  3. Auto scale based on a defined schedule

azure vmss scale out

You can configure scaling options either at the time of creating the virtual machine scale set or after it is created. At the time of creating the scale-set, you configure scaling on the Scaling tab as you can see from the image below.

manual upgrade virtual machine scale set

Virtual machine scale set - Manual Scale

azure vmss manual scale

In the azure portal, navigate to your virtual machine scale set. Click on Scaling tab under Settings. To scale manually, specify the number of VM instances in the textbox provided. In a real world, it's a bit tedious and time consuming if we have to manually scale-out and scale-in everytime the demand for our application changes. However, it's an option, just in case, if you want to manually scale.

Virtual machine scale set - Custom Auto Scale

There are 2 ways to auto-scale. Auto scale based on metrics. For example, the following auto-scale condition increase the VM instance count by 1, when the average CPU utilization is greater than 70%. The instance count is decreased by 1, when the average CPU utilization falls below 25%.

virtual machine scale set autoscale

Auto scale based on a schedule to a specific instance count. The following scale condition increases the total instance count to 3 on Jan 1, 2021 and on Jan 5, 2021 it falls back to the baseline configuration.

vmss autoscale

Scale to a specific instance count can be repeated on specific days of the week.

virtual machine scale set scaling

If you get the error - The subscription is not registered to use namespace 'microsoft.insights

  1. Navigate to your Subscription blade in the azure portal
  2. Click on Resource Providers
  3. Search for Microsoft.Insights
  4. Select it and click Register

the subscription is not registered to use namespace 'microsoft.insights'

Failed to update configuration for 'vmss-demo'. {"error":{"code":"MissingSubscriptionRegistration","message":"The subscription is not registered to use namespace 'microsoft.insights'. See https://aka.ms/rps-not-found for how to register subscriptions.","details":[{"code":"MissingSubscriptionRegistration","target":"microsoft.insights","message":"The subscription is not registered to use namespace 'microsoft.insights'. See https://aka.ms/rps-not-found for how to register subscriptions."}]}}.

Summary

If your application demand increases, the load on the VM instances in your scale set also may increase. If this increased load is consistent, rather than just a brief demand, you can configure autoscale rules, both to increase and reduce the number of VM instances in the scale set.

Azure tutorial for beginners





© 2020 Pragimtech. All Rights Reserved.