AWS Lab 10 : EC2 Linux & Auto-scaling group

AWS Lab 10 : EC2 Linux & Auto-scaling group

Duration: 45 minutes

Part:1 Create simple web-server & AMI

Create an instance : Amazon Linux
Type : t2.micro
With default 8 GB root disk (/)
Install http webserver
Update index.html –> WELCOME to my AUTOSCALE-WEBSERVER
Browse your public IP and verify the webpage for above line.
Create an AMI from this instance as “Autoscale-Webserver-AMI-01″

Part:2 Create a Auto-Scaling Launch Configuration

– Create Launch configuration “my-launchconfig-01″ with below:
– Use an AMI “Autoscale-Webserver-AMI-01″
– Instance type t2.micro
– Security group to allow TCP 80 to all & TCP 22 to your IP

Part:3 Create a Auto-Scaling group

Create auto-scaling group “my-autoscale-group-01″

Choose your launch configuration “my-launchconfig-01″

Starts with 1 instance  and scale between 1 to 4

Configure to launch an instances on all the availability zones of “us-east-1″ region

Create Increase group policy & add alarm to check  CPU > 50% add 1 instance & send email note to “yourid@email.com”

Instance needed – 60 seconds (default 300 sec)

Create Decrease group policy & add alarm to check  CPU < 20% remove 1 instance

Part:4 Run the following script to load your instances CPU to scale up

After, part-3 you should see 1 out of 4 Linux instance launched & running.

Connect to the Linux instance and run the following script to increase the CPU load.

vi dd.sh
dd if=/dev/zero of=/dev/null bs=50000 count=100000
dd if=/dev/zero of=/dev/null bs=50000 count=100000
dd if=/dev/zero of=/dev/null bs=50000 count=100000
dd if=/dev/zero of=/dev/null bs=50000 count=100000
dd if=/dev/zero of=/dev/null bs=50000 count=100000
dd if=/dev/zero of=/dev/null bs=50000 count=100000
dd if=/dev/zero of=/dev/null bs=50000 count=100000
:wq!

# chmod 755 dd.sh

# nohup ./dd.sh &

run a “top” command and verify the CPU usage

Wait for 60 seconds & check for new instance launched by auto-scaling group.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>