Ben already wrote an awesome blog about one-click integration with autoscaling. But as one of our eagle-eyed customers politely pointed out - it doesn't actually explain how to configure AWS Auto Scaling in the first place!

So, I wanted to run through the steps in much more detail, my aim being to have a simple quick start guide on how to get auto scaling configured, first in AWS and then on our Advanced Load Balancer ADC for AWS.

Please feel free to comment below if I have failed :-)

This may not be the blog you were looking for...

The Loadbalancer.org appliance automatically detects changes in your auto-scaling groups, with zero configuration and zero downtime. If for some' crazy reason you don't want to pay for our load balancer and want to use Amazons built in one - then checkout the excellent AWS Auto Scaling documentation.

Still with me? Sweet, so what do you have to do?

Firstly, we will start with AWS and get your launch template and auto scaling group setup. Once the auto scaling group is configured and ready to go we will then configure the load balancer and watch the magic happen.

AWS Tasks

1: Create a Launch Template
2: Create an Auto Scaling Group
3: Verify Your Auto Scaling Group
4: (Optional) Delete Your Scaling Infrastructure

Loadbalancer.org Tasks

Configure a virtual service on the load balancer.

Note:
We will be using 2x IIS web server instances for testing (ami-7ff24306) throughout this document.

So let's get started...

Step 1: Create a launch template

ec2_aws_consoleupdated

  • On the navigation bar, select a region.

Note:

ec2_regionupdated

  • On the navigation pane, choose Instances, Launch Templates.

launch_templates_image3-3

  • Choose Create launch template

create_launch_template

  • Provide a name and description for the launch template.

Note:

  • The name of a launch template must have 3 to 125 characters, and can include the following characters: ()./_.
  • For AMI ID, type the ID of the AMI for your instances.
  • For Instance type, select a hardware configuration for your instances that is compatible with the AMI that you specified.
  • (Optional) For Key pair name, type the name of the key pair to use when connecting to your instances.
  • For Network interfaces, configure Subnet, Auto-assign public IP, and Security group ID. Leave Primary IP and the other fields empty and this creates a primary network interface with IP addresses that we select for your instances.

create_launch_template2updated4-2

  • (Optional) For Storage (Volumes), specify volumes to attach to the instances in addition to the volumes specified by the AMI you specified.
  • (Optional) For Tags, specify one or more tags to associate with the instances and volumes.
  • Choose Create launch template.

create_launch_template3updated5

  • On the confirmation page, choose Create Auto Scaling group.

create_autoscaling_grp5updated9-1

Step 2: Create an Auto Scaling Group

Note:

  • An Auto Scaling group is a collection of EC2 instances, and the core of Amazon EC2 Auto Scaling. When you create an Auto Scaling group, you include information such as the launch template, the subnets for the instances, and the number of instances the group must maintain at all times.

To create an Auto Scaling group

  • On the Configure Auto Scaling group details page, do the following:

  • For Launch template version, choose whether the Auto Scaling group uses the default or the latest version of the launch template when scaling out.

  • For Group name, type a name for your Auto Scaling group (for example, my-first-asg).

  • Keep Group size set to the default value of 2 instance for this tutorial.

  • (Optional) To override the network in the launch template, select a virtual private cloud (VPC) for Network.

  • (Optional) To override the subnets in the launch template, select one or more subnets for Subnet.

  • Choose Next: Configure scaling policies.

create_autoscaling_grp1

  • On the Configure scaling policies page, select Use scaling policies to adjust the capacity of this group and input your minimum and maximum instance scale.
  • For the purpose of this tutorial I have chosen to scale between 2 and 4 instances.
  • Click the Scale the Auto Scaling group using step or simple scaling policies

create_autoscaling_grp1updated6

create_autoscaling_grp3updated7

  • Create a simple scaling policy for increasing and decreasing the instance group size.
  • Enter the Name of your policy for example Increase group size and Decrease group size.

create_autoscaling_grp4updated8

  • At Take the action enter the number of instances that you would like added and removed to and from the group, in this case we will use 1 instance.
  • Leave Instances need field empty to default to 300 seconds.
  • Click add new alarm to execute the policy when your requirements are met.
  • In this case when the server reaches a CPU utilization equal to or greater than 70% for 1 consecutive period of 5 minutes 1 instance will be created.

create_alarm_high

  • Click Create Alarm
  • Click add new alarm of the Decrease group size policy to execute when your requirements are met.
  • In this case when the server reaches a CPU utilization less than or equal to 69% for 1 consecutive period of 5 minutes 1 instance will be removed.
  • Click Create Alarm

create_alarm_low

  • Choose Review.
  • On the Review page, choose Create Auto Scaling group.

create_autoscaling_grp5updated9

  • On the Auto Scaling group creation status page, choose Close.

auto_scaling_grp_closeupdated10

Step 3: Verify Your Auto Scaling Group

  • Now that you have created your Auto Scaling group, you are ready to verify that the group has launched an EC2 instance.

To verify that your Auto Scaling group has launched an EC2 instance

  • On the Auto Scaling Groups page, select the Auto Scaling group that you just created.
  • The Details tab provides information about the Auto Scaling group.

verify_autoscale_grpupdated11

  • On the Activity History tab, the Status column shows the current status of your instance. While your instance is launching, the status column shows In progress. The status changes to Successful after the instance is launched. You can also use the refresh button to see the current status of your instance.

activity_historyupdated12

  • On the Instances tab, the Lifecycle column shows the state of your instance. You can see that your Auto Scaling group has launched your EC2 instance, and that it is in the InService lifecycle state. The Health Status column shows the result of the EC2 instance health check on your instance.

instancesupdated19

  • (Optional) If you want, you can try the following experiment to learn more about Amazon EC2 Auto Scaling. The minimum size for your Auto Scaling group is 1 instance. Therefore, if you terminate the running instance, Amazon EC2 Auto Scaling must launch a new instance to replace it.

  • On the Instances tab, select the ID of the instance. This shows you the instance on the Instances page.

  • Choose Actions, Instance State, Terminate. When prompted for confirmation, choose Yes, Terminate.

  • On the navigation pane, choose Auto Scaling Groups. Select your Auto Scaling group and chose the Activity History tab. The default cooldown for the Auto Scaling group is 300 seconds (5 minutes), so it takes about 5 minutes until you see the scaling activity. When the scaling activity starts, you'll see an entry for the termination of the first instance and an entry for the launch of a new instance. The Instances tab shows the new instance only.

  • On the navigation pane, choose Instances. This page shows both the terminated instance and the running instance.

Step 4: (Optional) Delete Your Scaling Infrastructure

You can either delete your scaling infrastructure or delete just your Auto Scaling group and keep your launch template to use at a later time.

To delete your Auto Scaling group

  • Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  • On the navigation pane, under Auto Scaling, choose Auto Scaling Groups.
  • Select your Auto Scaling group (for example, Test-asg).
  • Choose Actions, Delete. When prompted for confirmation, choose Yes, Delete.
  • The Name column indicates that the Auto Scaling group is being deleted. The Desired, Min, and Max columns shows 0 instances for the Auto Scaling group.

Note:

  • Skip this procedure if you would like keep your launch template.

To delete your launch template

  • On the navigation pane, choose Instances, Launch Templates.
  • Select your launch template (for example, my-first-lt).
  • Choose Actions, Delete template. When prompted for confirmation, choose Delete launch template.

Loadbalancer.org Tasks

  • Configure a virtual service on the load balancer
  • Once you have your auto scaling group you can configure your service to load balance. The appliance supports auto scaling groups when using layer 4 TCP/ UDP, layer 7 also with SSL termination. Here I am creating a layer 7 HTTP service listening on 10.0.200 port 80.

lb_create_l7_VIP

lb_create_l7_VIP2

  • After you have added your service you need to modify your new service and this will show you more options. We only need to make a change to one of these options and add our Auto scaling group name and Auto scaling backend server port (if left blank the port will default to the frontend port) to the configuration and update.

lb_modify_l7_VIP

lb_modify_l7_VIP2

  • Once updated you will be prompted to restart HAProxy and the auto scaling service to complete the configuration. When the services have been restarted the load balancer will start monitoring your auto scaling group and your servers will be shown in the system overview with the server name as the instance id.

lb_restart_services_image23-1
System overview showing auto scaled servers

  • Now when any changes are made to the servers in the auto scaling group the load balancer will automatically be updated to reflect the changes.

lb_sysoverview_complete

For further details on how to configure the Loadbalancer.org appliance for AWS please see our AWS Quick Start guide here

Additionally if you require any further assistance please contact us directly on support@loadbalancer.org - our engineers will be happy to assist you getting setup.