Azure Virtual Machine Scale Set & Auto Scaling
Virtual Machine scale sets
The scale sets are Azure compute resources that can be used to deploy and manage identical VMs. They are designed to support virtual machine auto-scaling. VM scale sets can be created using the Azure portal, JSON templates, and REST APIs. To increase or decrease the number of VMs in the scale set, we can change the capacity property and redeploy the template. A virtual machine scale set is created inside VNET, and individual VMs in the scale set are not allocated with public IP addresses.
Any virtual machine that we deploy and is the part of the virtual machine scale set will not be allocated with a public IP address. Because sometimes, the virtual machine scale set will have a front end balancer that will manage the load, and that will have a public IP address. We can use that public IP address and connect to underlying virtual machines in the virtual machine scale set.
Virtual Machine Auto Scaling
Autoscale enables us to dynamically allocate or remove resources based on the load on the services. You can specify the maximum and the minimum number of instances to run and add or remove VMs based on a set of rules within the range.
The first step in auto-scaling is to select a metric or time. So, it can be a metric based auto-scaling, or it can be a schedule based auto-scaling. The metrics can be CPU utilization, etc., and the time can be like the night at 6 o'clock till morning 6:00, we want to reduce no of servers. We can have a schedule based auto-scaling. In case if we're going to reach according to load, then we can use metric based auto-scaling.
The next step in the auto-scaling is to define a rule with the condition. For example - if the CPU utilization is higher than 80 percent, then spin off a new instance. And once the condition is met, we can carry some actions. The actions can be adding or removing virtual machines, or it can be sending email to a system administrator, etc. We need to select whether it is a time-based auto-scaling or metric-based, and we need to choose the metric. We define the rule and actions that need to be triggered when the condition in that rule is satisfied.
Horizontal and Vertical scaling
Metrics for Autoscaling
Tools to implement Auto Scale
Scaling Azure Virtual Machine
Step 1: Go to Azure Marketplace and type in the Virtual Machine scale set. Then click on Create.
Step 2: We need to give a name to this scale set. And fill all the other required details, as shown in the figure below. Then click on create.
Step 3: Now, your Virtual Machine scale set is successfully deployed. To view VMSS, you can go to resources.
Step 4: Now, click on scaling. Provide an auto-scale setting name. And select the resource group.
Step 5: Scroll Down, and you will find two ways to auto-scale. First, click on "add a rule? for auto-scaling based on the metric. We are going to scale our virtual machine if the average percentage of CPU utilization is above 70 percent.
Step 6: Now, select the time and date based scaling, where you can scale when you need more space. And the last thing is Notify, where you get notified whenever the auto-scaling gets triggered.