Auto Scaling
Auto Scaling
AUTO SCALING
BOOT STRAPPING
When you launch an instance in Amazon EC2, you have the option of passing user
data to the instance that can be used to perform common automated configuration
tasks and even run scripts after the instance starts.
You can also pass this data into the launch wizard as plain text, as a file (this is
useful for launching instances via the command line tools), or as base64-encoded
text (for API calls).
Navigate to the EC2 dashboard from the AWS Console and select Instances,
located in the left bar under INSTANCES.
Enter the below the commands in the text field, then choose Next.
#!/bin/bash
yum install httpd php -y
service httpd start
chkconfig httpd on
echo "<?php phpinfo(); ?>" > /var/www/html/index.php
Then go with normal process for creating a new instance, make sure you have
selected a security group which has 80(HTTP) port open.
Once instance launched, you can browse the IP Address assigned to instance by
AWS.
You will be displayed with PHP Info page with all PHP settings.
HORIZONTAL VS. VERTICAL SCALING
Horizontal scaling means that you scale by adding more machines into your pool
of resources.
Vertical scaling means that you scale by adding more power (CPU, RAM) to your
existing machine
Navigate to the EC2 dashboard from the AWS Console and select Launch
Configurations, located in the left bar under Auto Scaling.
Choose Create Auto Scaling group under Welcome to Auto scaling page.
AWS will provide you with a page giving you an overview of Auto Scaling group
creation. Click Create launch configuration.
Under Create Launch Configuration page, choose My AMIs from left pane, choose
your AMI by clicking on Select.
leave everything with the default settings. Go to Next: Configure Security Group
Choose existing security group or create a new one by adding required ports and
choose Review.
AWS will provide you with a page giving you review of all your settings, click
Create launch configuration.
You will be asked for Key pair choose existing or create a new one, then choose
Create launch configuration.
AWS will provide you with a page to Create Auto Scaling group.
Specify a group name, we will start with 2 instances for high availability.
Select VPC from the VPC drop down list, add subnets under subnet section.
Then expand Advanced Details.
Then set Take the action to Remove 1 instances. Press next configure notifications.
AWS will provide you with a page giving you review of all your settings, click
Create Auto Scaling Group.
Then go to Instances page to see the instances which were started creating.
Then go to Load Balancers section, select your load balancer, choose instances tab,
you can see instances from two AZ’s attached to ELB and status is in service.
Then select Description tab, you can see the DNS name for ELB, copy and browse
your application which is auto scaled and high available.
If you want to test self-healing, we can delete one instance which is created by
Auto Scaling, Auto Scaling will automatically launch a new instance to meet the
minimum requirement which put as 2 instances.