Creating a Virtual Machine Scale-Set in Azure (VMSS).
Tags: azure
Published: 2024-06-26 12:24:35

## What is Virtual machine scale-set?
One intriguing feature provided by Microsoft Azure is called Virtual Machine Scale Sets (VMSS), which aids in the creation and management of a group of similar, auto-scaling Virtual Machines (VMs). VM instances can be automatically increased or decreased in accordance with predetermined parameters.

VMSS may be used to launch a collection of virtual machines (VMs) with the same operating system, applications, and data settings. In addition to offering load balancing, intelligent scaling, and connectivity with other Azure services, VMSS is a strong and adaptable tool for handling heavy workloads.

All things considered, VMSS is a significant Microsoft Azure feature that offers a scalable and reliable way to build and manage a group of similar virtual machines.

**Auto-Scaling**
With auto-scaling, you may set an automated limit on the amount of computing resources your application uses, according to how much it requires at any given time.

The main takeaway is that, regardless of how quickly or slowly, large or little, your site grows over time, you can now create a scalable architecture that will automatically scale up or down to meet your demands.

These are the most often used auto-scaling methods:

- 
Horizontal Scaling

- 
Vertical Scaling


![Types of scaling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6jmoecfdi5op8rraj49.png)

**Vertical Scaling**
If you have a single core processor and four gigabytes of RAM in vertical scaling, you may upgrade to a dual core processor and eight gigabytes of RAM. We refer to this as **Scale UP**. Scaling down means returning the configuration to its initial state.

**Horizontal Scaling**
Horizontal scaling, also known as scale out, is the process of starting with one virtual machine and gradually adding others with the same configuration. Once your sale or business requirement is met, you may also scale down to 1 virtual machine (VM). This technique is known as "**scaling in**."

Distributed architecture is required because applications are usually spread over several instances, allowing for redundancy and enhanced performance. A load balancer distributes requests to one of the application instances in order to provide your customers with quicker speed and lower latency.
Virtual Machine Scale Set (VMSS) let you 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.

![VMSS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5wih4whiho5ninvp659.png)

## Creating a Virtual Machine Scale Set in Azure.

Sign in to the [Azure portal](https://portal.azure.com)
You can deploy a scale set with a Windows Server image or Linux image

- In the Azure portal search bar, search for and select _Virtual Machine Scale Sets._

![VSS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjvsur383ho9rttqrh14.png)

- Select **Create** on the Virtual Machine Scale Sets page.

![VSS create](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cehi0km4n3qoton0lrc4.png)

- 
In the Basics tab, under Project details, make sure the correct subscription is selected and create a new resource group called **vmssRG**.

- 
Under **Scale set details**, set _myScaleSet_ for your scale set name and select a **Region** that is close to your area.


![Create a VMSS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrwfx5msfsh8hpvs3mv5.png)


- 
Under **Orchestration mode**, select _Uniform_.
- 
Under the Security type blade select _Standard._ 

- 
Under Instance details, select a marketplace image for Image. Select any of the Supported Distros.

- In **Scaling mode** choose the _Autoscaling option_. Then select _Configure_ to set parameters for the scaling configuration.


- 
In the **Instance count** section enter _2_ (Indicating initial creation of 2 VMs). Then select _Configure._

-Under the **Scaling condition**, click the _Add a scaling condition_


![Scaling settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rx5qv1gjyvg4sp3zpls0.png)

![Scaling condition](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q67uo26xl596ybxp8l8a.png)

![Scaling configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vqtmegmwt67d380049x.png)

- Set the parameters as indicated below.

![Scaling options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jixc79ix8jzpuk2xicl9.png)


![Scaling options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcakd37bvycuwgvslsk4.png)

- 
Under **Schedule** select _Specify start/end dates._

- 
Select your time zone in the **Timezone** blade as well as the **start date**.
- 
Click on the **Save button**


![Scaling options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bz000ddxi8p0u0uz0fow.png)


- 
Under **Instance details**, select a marketplace image for Image. Select any of the Supported Distros.

- 
Under the **Size blade**, select Standard_D2sv3 - 2 vcpus, 8 Gib memory.

- 
Under Administrator account configure the admin username and set up an associated password or SSH public key. (_In this demo, we will generate a new key pair._)

- 
Next, set your username,  and in the SSH public key source field, select _RSA SSH Format._

- 
Enter the **Key pair name.** In this demo the key name is vmssKey

![VMSS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/93vhkwqhilrrtrsacp56.png)


![Account setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4xd82vy41fuh8r6osk8.png)

- 
Select **Next: Disks** to proceed to the Disk configuration options. For this quickstart, leave the default disk configurations.

- 
Select **Next: Networking** to move to the networking configuration options.


- On the Networking page, under **Load balancing**, select the _Use a load balancer_ radio button to put the scale set instances behind a load balancer.


![Load balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lc6bggugpbs2okx4oyfe.png)


![Load balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmfw4ptlo5xolpkx63un.png)


- In the **Select load balancer** options, select _Create load balancer_.

- Give the **Load balancer** a name - _vmss-lb._


![Load balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfkh1lka3ia1oauwwo4z.png)


![Load balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmg23b6s3w2jvv33skv8.png)

- Click on **Next** to advance to the networking page and edit the network interface options as indicated below.

![editing the network interface options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uo77e9piiwcf5vsyjm4b.png)



![editing the network interface options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mb2haz95cgkk7nbz8s91.png)




- 
Review and create.

- 
After it passes validation, select **Create** to deploy the scale set.


![Validation passed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7bo8yuivhv147xiwqqn.png)

- Select the **Download private key and create resource**


![New key pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocw7sv44bz3tikuf0euz.png)

- 
After the deployment is completed, click on the **Go to resource** button.


![deployment completed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40jnesnedjmfry46p0y0.png)

- 
Select **Instances** to see the two default VMs created as indicated in our configuration.



![Instances](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tf9kmnmv9ottslcwfy5b.png)

- Go to the **Load balancing** blade and select the _Frontend IP address._

- Next step is to open **commamd prompt (cmd)** to connect via SSH to the VM.



![Connecting to the VM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rixo5djaabmlj07w5x6v.png)


![Connection succeeded](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7mdln3oeeq7ya5y9cr4y.png)

- 
Update the VM and install the webserver using the linux commands.

`sudo apt-get -y update
sudo apt-get -y install nginx`


![webserver page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jd8ub9cfwg56kuhk1had.png)

## Setting up a stressor for the VMs to test the scale sets

- 
Adding a workload to the VMs
- Type the linux command

```
sudo apt-get install stress-ng
```

- 
Linux Stress command 

```
stress-ng --cpu 4 --tz -t 1024
```


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pqb8ujy48zpth7meavw4.png)

- 
Another instance of the VM has been created due to the increase in workload.