Monday, 3 August 2020

Auto scaling

Scenario:
When we have multiple EC2 instances are running for our application when there is high load on the servers , sometimes we need to increase the servers based on the load and sometimes we do not need additional servers for our application when there is a less load.

To manage this automatically creating servers(EC2) and automatically removing servers when the job is done , AWS having an amazing feature called "Auto scaling", so that we can make cost effective solution with high availability and fault tolerance.

There are two types  of scaling i.e. 
Vertical scaling : increasing the capacity like CPU,memory of AWS resources.
Horizontal scaling: Adding same resources based on the requirement, For ex: adding EC2 instances.

Auto-scaling automatically integrate with Load balancer.

Launch configuration: 

A template given to auto scaling to launch instances., template contains the below
  • AMI
  • IAM role
  • Instance type
  • security group
  • EBS volumes
  • Key name(Pem file),

Auto scaling group:

  • Min size
  • Max size
  • Desired capacity

Scaling policies

The policy which has action to add or removing instances

How we setup auto scaling

Create a classic load balancer for this case

See the steps for the steps how we can create Classic balancer but when there is a step to add instances to the load balancer , don't add EC2 instances, lets create those instances by using the Auto scaling.

See the below(Once done creation of LB, click on Instances tab)

Create launch configuration

Create two EC2 instances and create an AMI for Web-01 instance.



Click "Create autoscaling" button.

Now create launch configuration

  • Give a name: launch config
  • select AMI: Simple auto scaling(which we created)
  • Instance Type: t2.micro
  • Security group: select the same SG which u have used for EC2
  • select Keypair and name of it.
  • Click on "Create launch configuration" with other default values.

Configure Auto scaling





Creating Tags for the EC2s which are created by Auto scaling.


Now auto scaling group is created as below



Just refresh your screen , you can see Instances:1 and see load balancer for the instances , because earlier you haven't added instances to LB. 


Check the DNS by opening in the browser.


EC2 is created with our customized tag.


We stopped the EC2 which is created by autoscaling as i selected above.

Now we can see the activity what happened with EC2 instances in Autoscaling.



This is a simple demo which we can create just one instance by auto scaling group.


Thank you for reading 👍👍👍👍👍👍👍👍

No comments:

Post a Comment