Auto Scaling in AWS

Posted: April 22, 2017 in Amazon Web Services (AWS), Linux

Auto Scaling is mechanizam which enables Amazon EC2 instances availability to handle the load for application. We create collections of EC2 instances-Auto Scaling groups. We can specify the minimum number of instances in each Auto Scaling group, and Auto Scaling ensures that group never goes below this size.

In this example we’ll create highly available web server

In this post we created EC2 instance,during this creation we can specify BootStrap script which can automatically configure VM during creation.

I uploaded example html file to one of my bucket,didn’t specify any permissions

1.PNG

This file will be copied to Amazon VM during it’s creation,we’ll also install Apache by BootStrap script

I created a role and assigned it AmazonS3FullAccess Policy

2.PNG

#!/bin/bash
yum install httpd -y
yum update -y
aws s3 cp s3://bucket-irleand/index.html /var/www/html/index.html
service httpd start
chkconfig httpd on

This role will be specified during VM creation (EC2 instance is in the same region my bucket-Irleand)

2.PNG

Creating Elastic Load Balancer

Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances.,it enables  fault tolerance in applications

Services-EC2-Load Balancers

1.PNG

Create Load Balancer

1

Application load balancers routes traffic on Application Layer,Classic Load Balancer on 4th OSI layer

1.PNG

Choose subnets and protocols

1.PNG

We got warning because we don’t have SSL certificates

1

Create new or choose existing Security group

1.PNG

Create new group,choose port and protocol,specify path (if path doesn’t exists it would declare load balancer as unoperational

1.PNG

Healthy treshold:Number of consecutive healthy checks successes before load balancer is considered unhealthy

Unhealthy treshold:Number of consecutive healthy checks failure before load balancer is considered unhealthy

Timeout:Number of seconds after balancer is considered unhealthy

Interval:Number of seconds between health checks

Select instance which will be part of Balancer in instances section-click Add to registered,instance will show in Registered instances field

1.PNG

Copy Load Balancer DNS to browser and test access

1.PNG

1.PNG

Now, click Launch Configuration

1.PNG

Click Create Auto Scaling Group

1.PNG

Then click Create Launch Configuration

1.PNG

1.PNG

1.PNG

Add IAM role (as we did for first machine) and specify same BootStrap script

1.PNG

Add Storage

1.PNG

Specify Security Group and Key Pair

1.PNG

1.PNG

Specify number of instances (one instance will be created in every subnet),subnets

Click Advanced and specify load balancer,because i created application load balancer i need to specify target group created earlier and select Health Check type

1.PNG

Specify Health Check Grace Period,in our case this is time needed for BootStrap script to execute,if our script needs more time, we need to specify it here

1.PNG

1.PNG

Create Auto Scaling Group

1.PNG

And tags:

1

After Auto Scaling group starts to initialize new AWS instance will be created with our html file being copied from bucket and apache service installed,so if any of those instances fails, other will take over

 

1.PNG

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s