Azure virtual machine scale sets lets us to create and manage a group of load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule. Scale sets provide high availability to your applications, and allow to centrally manage, configure, and update a large number of VMs. With virtual machine scale sets, we can build large-scale services for areas such as compute, big data, and container workloads.

Why use virtual machine scale sets?

  • Easy to create and manage multiple VMs
  • Provides high availability and application resiliency
  • Allows your application to automatically scale as resource demand changes
  • Works at large-scale

In this post, lets see how to deploy VM Scale Sets using custom auto scale option

Click on create virtual machine scale set

Fill the Basic details, like Sub, resource group, Scale Set Name & Region. Chose the region name as per your Availability zone requirements

Microsoft Azure services are available globally to drive cloud operations at an optimal level. You can choose the best region for your needs based on technical and regulatory considerations: service capabilities, data residency, compliance requirements, and latency.

Regions and Availability Zones in Azure | Microsoft Docs

Choose your disk types

Choose the vNET and Network interfaces as desured, and if you want to set it to Accelerated networking change it now, You will not be able to change it at a later stage.

Autoscale is a built-in feature that helps applications perform their best when demand changes. You can choose to scale your resource manually to a specific instance count, or via a custom Autoscale policy that scales based on metric(s) thresholds, or schedule instance count which scales during designated time windows. Autoscale enables your resource to be performant and cost effective by adding and removing instances based on demand

Depending on your requirement please choose the initial instance count, Scaling policy in this post lets see custom and specify the minimum and maximum number of instances(Between 0-100)

Next is the Scale out and scale in threshold, Again this is something depending on your application, requirements choose the scale out option wisely.

I am also sending the logs to my workspace as below,

Testing Scale out and Scale in

So to validate my scaling configuration, Lets try to test this scenario and see how the scale set works. I have Selected a cent OS machine in this post, So lets try to add some CPU stress in this VM

Install EPEL Repository on CentOS Server
yum search epel-release
yum info epel-release
yum install epel-release

Install stress

yum install stress

After I install stress. Lets try to run CPU Stress,

you can see the CPU spike caused by stress,

If you see in the logs and the scale sets, you should start seeing new instances.

As you can see the new instances are added to the scale set.

Now lets try to kill the stress process and see

CPU utilization is back to normal
Instances are getting deleted based on the scaling policy,

Now lets see the log analytics workspace,

In this you can see the current instances count over a period of time

Thank you! In the next post lets see a different scenario