DEV Community

Cover image for Load Balancer and Virtual Machine Scale set
Yemisi Oyesainu
Yemisi Oyesainu

Posted on

Load Balancer and Virtual Machine Scale set

Load balancers and Virtual Machine Scale sets are different tools or services, but both are excellent infrastructure for achieving scalability and high availability of applications in Cloud environment.

Before we embark on highlighting how the two works, let's look at what each of them really are.

Load Balancer is a networking component or service that distributes incoming network traffic across multiple backend servers, virtual machines, or other resources. As the name implies, it balances workload across these resources. It can be implemented as software or hardware appliances or as cloud-based services provided by cloud platforms.
Its main features are
(i)traffic distribution
(ii)resources health monitoring
(iii)session persistence
(iv) SSL termination

There are different types of Load balancers classified based on specific needs and requirements. They are
(i)Local/Network Load Balancer or Transport Layer Load Balancer: This operates at the network layer (Layer 4) of the OSI model distributing workload based on IP addresses and port numbers. They are often hardware appliances or software solutions specifically designed for local or on-premises network environments.
(ii)Application Load Balancer (ALB) or Application Layer Load Balancer:It runs at the application layer (Layer 7) of the OSI model making the load balancing decisions based on information within the application layer protocols, such as HTTP headers, URLs, or cookies. ALBs are commonly used for HTTP(S) traffic and provide advanced features like content-based routing, SSL termination, and session persistence.
(iii)Global Load Balancer: distributes traffic across multiple data centers or regions, allowing load balancing on a global scale. It directs requests to the nearest or least loaded data center, reducing latency and improving performance. Generally, it is used for multi-region architectures to achieve high availability and global traffic optimization. Examples of GLB architectures are DNS hosting solutions, such as Infoblox and CloudFlare; DNS service of a major public cloud providers like AWS Route53, Azure Traffic Manager.
(iv)Software Load Balancer: These are implemented in software and run on standard servers or virtual machines. They provide load balancing functionality without the need for specialized hardware appliances. Software load balancers are flexible and scalable, often used in cloud environments or virtualized infrastructures.
(v)Reverse Proxy Load Balancer: This is located between clients and backend servers, acting as a proxy for incoming requests. It receives the client requests, performs load balancing, and forwards the requests to the appropriate backend server. They are often use in handling incoming web traffic, providing SSL termination, and offering advanced caching or content delivery capabilities.
(vi)DNS Load Balancer: This distributes traffic by leveraging the DNS (Domain Name System) to resolve domain names to multiple IP addresses. It can direct clients to different IP addresses based on factors like geographic location or server health. DNS load balancing is an effective approach for balancing traffic across multiple resources or locations.

Virtual Machine Scale Set (VMSS) is a tool or service provided by cloud computing platforms, such as Microsoft Azure, that enables the management of a group of identical virtual machines as a collective unit.
Other important features and benefits of VMSS includes
(i)It makes deployment and management of multiple virtual machines easy by automatically creating, scaling, and distributing them based on predefined policies.
(ii)In VMSS, scaling rules and conditions are defined to automatically add or remove virtual machine instances based on demand. Adding more VM Instances is referred to as scaling out while reducing number of VM Instances is known as scaling in
(iii) It is used to update and maintain the virtual machines within the set, and this include rolling upgrades and fault domain support.

You can have more control over the way the scale set manages virtual machine instances by using the orchestration modes. When creating VMSS, the orchestration mode is defined and this can not be modified after the deployment of the scale set.
There are two main types of orchestration modes:

(i)Scale sets with Uniform orchestration: It is optimized for large-scale stateless workloads with identical instances.
It uses a virtual machine template to scale up to desired capacity. It also uses identical VM instances though it has some ability to manage or customize individual virtual machine instances. Individual Uniform VM instances are exposed via the Virtual Machine Scale Set VM API commands. When it is configured with less than 100 instances, it provides fault domain high availability. It supports a full range of scale set management and orchestration, including metrics-based autoscaling, instance protection, and automatic OS upgrades.

(ii)Scale sets with Flexible orchestration: This achieves high availability with identical or multiple virtual machine types. Up to 1000 VMs can be provisioned in the orchestration mode. These are spread across fault domains in a region or within an Availability Zone making scaling out easily achievable. This orchestration mode works with all sizes of virtual machines.

How does Load balancer and Virtual Machine Scale set work together?
A load balancer receives incoming network traffic from clients. It then distributes the traffic across the virtual machines within a Virtual machine scale set. The workload is evenly distributed preventing any single virtual machine from being overwhelmed.

When demand for your application increases, a VMSS can automatically scale out by adding more virtual machine instances to handle the increased load. The load balancer ensures that the incoming traffic is distributed across all the available instances, enabling horizontal scaling and providing additional capacity.

If for any reason a virtual machine within the scale set becomes unavailable or unhealthy, the load balancer will redirect the workload meant for that Virtual machine to the remaining healthy instances, ensuring uninterrupted service enhancing applications high availability.

Load balancers performs regular health checks of each virtual machine instance within a VMSS and route traffic only to the healthy instances. If a virtual machine becomes unhealthy, the load balancer can automatically stop sending traffic to it until it recovers.

As I mentioned at the outset, you can see how Load balancers and Virtual machine scale sets work together to achieve scalability, high availability, and efficient traffic distribution for applications deployed in a cloud environment.

Let's proceed to Azure Portal to create a Load balancer and Virtual Machine Scale Set

(1)Log in to Azure Portal and type Virtual machine scale sets into the search bar

Image description

Image description

Click on 'Create'

Image description

Complete the Project details and Scale sets details
My Subscription is Azure Pass Sponsorship and my Resource group is UniRg.I will name the scale sets Abbyvmss and choose East US as the Region

I will leave Orchestration at default and choose the image as Windows Server 2019 under the Instance details

Image description

Complete details of the Administrator account.
My username is Azureuser and password is Password123*

Image description

(2)To configure Load balancer, click on 'Networking'

Image description

Under 'Networking' click on Azure load balancer
Next click on create Load balancer. I will name it balancer1
Then click 'Create'

Image description

To allow traffic from the Load balancer, we have to edit the Port configuration of the Network interface

Image description

Click on the Edit button on the left side of the V-net

Image description

Click on 'Allow selected ports' under Public Inbound Port

Image description

Select HTTP(80), RDP (3389) and Click OK

Image description

(3)Go to Scaling

Image description

I will leave the Initial Instance Count at the default of 2 and Scaling Policy at Manual

Image description

(4)Click on 'Health' and enable application health monitoring

Image description

Click on Review and Create

Image description

Click on Create and allow the deployment to complete

Image description

Image description

(5)Go to Resource

Image description

The Virtual machine scale set Abbyvmss has been created with load balancer and two virtual machine instances

Image description

Image description

The two VM Instances are running.

Trust you find this useful.Please proceed to the comment section and let's have your feedback

Top comments (0)