Visitor Counter

Visitor Counter

Saturday, May 16, 2020

Create Elastic Load Balancing and Auto Scaling Group

 

 

What is a Load Balancer? 

The load balancer is exactly what it sounds like It is a physical or virtual device that's designed to help you balance the load balance the network load across multiple web servers. if we've got a load balancer HTTP web server One, Two webserver Three, etc. It can balance the load across the three of them. You can also use it for applications it doesn't have to necessarily be Internet-facing load balances. but typically they are Internet-facing and primarily they're used to balance load across web servers.AWS has three different types of load balances

Load balancers Type

  1. Application load balance (Intelligent Layer 7)

  2. Network load balancer (Extreme Performances Layer 4 )

  3. Classic load balancer (Basic Load balancers with Low Cost)

     

Image Sources



Create load balancer with Autos scaling group

To do this you have to log in to your Amazone account

 

 Creating an Image from the Existing Instances

 

 

First of all, we are going to create an Image from the existing Instance then they both will be identical.

To do that go to the Ec2 instances and select the Web Server 1 then got to Action and Select Create Image and give the detail as below then Select Crate Image

 

 Image name: Web Server AMI


 Image description: Lab AMI for Web Server

 

 

Creating a Loadbalancer

 

Select Loadbalancer form the left side panel then Click Create Loadbalance.

You will get a three options namely -: Application Load Balancer,  Network Load Balancer, Classic Load Balancer

For this  Lab, we will select Application Load Balancer and add the details  below

 

 Name: LabELB


 VPC: LabVPC


 Availability Zones: Add the Both availability subnets 


Click Configure Security Settings

 

In the Security Settings

Select the Existing  Security Group

From the list Select Only the Web SecurityGroup

 

 

Click Configure Routing

 

 

 

In the Routing add the Details as below

Name: LabGroup 

Keep all the setting as the default

 

Click Register Targets 

 

In the Register Targets, you don't want to select anything just keep this setting as the default  

 

Click Review and  select Create

 

 

 Configuring the Auto Scaling Group

 

 

Here we are going to create the Configurations for the Auto Scaling this going to be the other scaling instances

Form the left side of the panel select Launch Configurations

 

Select the Create Launch Configurations. Under AMI  select My AMIs Then You will be able to see the Web Server AMI that we have created in the First step of this Lab, Select it 

 

 

 

 In Instance Type select

 

Instance Type as- t2.micro (It will be the default selected Instances)

Note: If you have launched the lab in the us-east-2 Region, select the  t3.micro instance type

 

  Click Configure details

 

 

 

Add the details as Below for the Configure details  Select Add Storage 

 

Name: LabConfig

Monitoring: Put the Tick for Enable CloudWatch detailed monitoring

 

In the Add, Storage keep the storage settings as the default

 

Click Configure Security Group

 

In the Security Settings

 

Select the Existing  Security Group

from the list Select Only the Web SecurityGroup

 

Click  Review 

 

After Clicking the Review  In the next window  

Click Create Launch Configuration

 

 

 

Then It will ask for the Key Pair select

Existing key pair from the Dropdown List

Give the key pair as  vockey

Select Create launch configuration

 

 

 

When the instance is created You will geta a message saying

 

Create an Auto Scaling group using this launch configuration  Select this 


Note-: Don't Select Close Button   

 

 

In the Configure Auto Scaling Group Details add the Details as below

Group name: Lab Auto Scaling Group


Group size: 2

Network: LabVPC


Subnets: Private Subnet 1 (10.0.1.0/24) Private Subnet 2 (10.0.3.0/24) This will help EC2 to work in Both AZ

 

 In the same page Under Advanced Details

 

Add the details as below 

 

Load Balancing: Put the Tick for Select Receive traffic from one or more load balancers


 Target Groups: LabGroup


 Monitoring: Put the tick for Select Enable CloudWatch detailed monitoring

 

Click Configure scaling policies

 

In the scaling policies, Select Use scaling policies to adjust the capacity of this group. and add Scale between  2 and 6

 

 In Scale, Group Size Add the details as below 


Metric type: Average CPU Utilization

Target value: 60

 

Click Configure Notifications

 

In the next window Configure Notifications

Keep the default Notification setting as it is

 

Click Configure Tags

 

 

 In the Tag add the details as below

 

 Key: Name


 Value: Lab Instance


Click  Review

 

Here You will be able to see the datils of your Autoscale Group 

 

Click Create Auto Scaling group

 

 

At the First time When you Click the Create Auto Scaling group, You will get this message 

 

Click Retry Failed Tasks

 

 

 After CLicking the Retry Failed Tasks  it Should Successful then Click Close

 

 

Verify that Load Balancing is Working

 

 

Select Target group form the left side panel, you will be able to see the Group name call LabGroup Click that one and after clicking that you will get this window. In this window select the Targets tab then you will be able to see the health of the targets The Two Targets Status Should be  Healthy.

 

 Note -: In the Instances, you should see two new instances named Lab Instance

 

Select Loadbalancer form the left side panel and select LabELB in the under the description menu (bottom of the window)  get the DNS name of the  Loadbalancer open a new tab in your Web Browser and paste the copied link then you will be able to see a web page as above.

Note-: If You Noticed carefully When you Click the AWS Log, The Availability Zon will change between (us-east-1a and us-east-1b) when the page is refreshed. This means the load is balanced between two AZ.

 

 

 

 Test Auto Scaling

 

 

To test  the Auto Scaling We are going to use Cloud Watch Services 

In the services  Under Management & Governance Select CloudWatch

From the left panel, click Alarms Then You Should be able to see the details as above

 

When The page is Loaded to the page You will be able to see the Alarms has been triggered

 

 

 

 

In this Alarm, it shows that  CPUUtilization>60 for 3 datapoints within 3 minutes

This means that the Intncase is overload and now it will autoscale and it will add more Instances.

 

 

In the Instances, you will be able to see the newly added Instance for Autoscaling 

 

 

 

What are the benefits and real-world example

If we think that we have a ticketing Web site and when the season comes it's peaking. So, for those days only, we need to balance our load on the Web. For this kind of situation, we can create load balancers in Multiple AZ when the load hits the web site it will balance the load across the AZ. Moreover, using Auto Scaling it will create the Instances it will help the webserver to configure resources automatically depending on requirements. Using these two services we can achieve some great benefits such as Increased Scalability, Redundancy, Reduced Downtime, Increased Performance are a few of them.

 

 

 

 

 

 

 

  References-:  

https://aws.amazon.com/elasticloadbalancing/

 

https://aws.amazon.com/elasticloadbalancing/

 

 

 

No comments:

Post a Comment

Click hear to Visit my Facebook