Amazon Auto Scaling using AWS Management Console

in #utopian-io6 years ago

What will I learn?

  • Prerequisites for Auto scaling
  • Advantages of Auto Scaling
  • Terminology used in Amazon Auto Scaling
  • How to Setup and Manage Amazon Auto Scaling Service?

Requirements

  • Basic C# programming
  • Basic knowledge of EC2 using spot instances

Difficulty

  • Basic

Introduction

What is Scaling?

Increasing or decreasing the computational resources according to the requirement is called as scaling. If your web application starts getting more traffic, you can either add more similar servers or increase the size (configuration) of your existing server.

Vertical Scaling:

Depending on your infrastructure, vertical scaling might involve changes to your server configurations (increasing the ram, cpu, storage) every time you scale.

Horizontal Scaling:

With horizontal scaling, you simply increase or decrease the number of servers according to your application’s demands. The decision when to scale vertically and when to scale horizontally depends on factors such as your use case, cost, performance, and infrastructure.

What is Amazon Auto Scaling?

Auto Scaling is a feature provided by Amazon web services (AWS) which is used for automatically adding or removing additional cloud resources (ec2 instances) based on the usage demand. Recently Amazon added auto scaling feature (through management console) to their cloud services.

According to Amazon:

Auto Scaling is a web service that enables you to automatically launch or terminate Amazon Elastic Compute Cloud (Amazon EC2) instances based on user-defined policies, schedules, and health checks. This service is used in conjunction with Amazon CloudWatch and Elastic Load Balancing services.

When you scale using Auto Scaling (horizontal) you can increase the number of ec2 instances you are using automatically when the user demand goes up (ex: website traffic) to ensure that performance is maintained, and the ec2 instances are automatically terminated when demand goes down to minimize costs.

image.png

When to Go for Auto Scaling Option?
  • Case 1: When the load on applications are constantly increasing.
  • Case 2: Very unpredictable load on the application, at peak hours there is too much load and during normal hours there is minimal load.
  • Based on the Amazon CloudWatch metrics you can decide when your application should scale up or scale down.
Prerequisites for Auto Scaling:

= One or more EC2 Instances

  • AMI
  • ELB
  • Amazon Cloud Watch
Advantages of Amazon Auto Scaling:
  • Availability: Amazon Auto Scaling ensures the most challenging problem of availability of the application, by starting and terminating the instances based on the health check tests and Cloud Watch reports.
  • Optimization: This is an important use of Amazon Auto Scaling, where it allows us to vary the size of our pools, based on usage, which saves money and allows us to adapt to unforeseen spikes without having an outage.
  • Flexibility: The flexibility of AWS Auto Scaling liberates you from having to accurately predict and provision servers in advance of huge traffic spikes.
Terminology Used in Amazon Auto Scaling
  • Auto Scaling Groups: When you are using Auto scaling, your EC2 instances are divided into Auto Scaling groups for the purposes of instance scaling and management. You create -
    Auto Scaling groups by defining the minimum, maximum, and, optionally, the desired number of running EC2 instances the group must have at any point in time.
  • Launch Configuration: Your Auto Scaling group uses a launch configuration to launch EC2 instances. You create the launch configuration by providing information about the image you want Auto Scaling to use to launch EC2 instances. The information can be the image ID, instance type, key pairs, security groups, and block device mapping.
  • Scaling Plan: A scaling plan tells Auto scaling when and how to scale?. You can create a scaling plan based on the occurrence of specified conditions (dynamic scaling) or you can create a plan based on a specific schedule (yes you can scale up or scale down at a particular time in a day.)
  • Amazon CloudWatch Alarms: A CloudWatch alarm watches a single metric (ex: cpu usage) over a specific period. The alarm has 3 states: OK, ALARM, INSUFFICIENT_DATA.
  • Scale Out: Increasing the number of Amazon EC2 instances.
  • Scale Up: Resizing the resources like processors, memory, and EBS storage of existing Amazon EC2 instances.
  • Scale Down: Decreasing (or terminating) the number of instances or the configuration of existing EC2 instances
  • Amazon Availability Zones (AZ): Nothing but the data centers of amazon located in multiple places.

How to Setup and Configure Amazon Auto Scaling Service?

1. Create Launch Configuration:
  • Login to Amazon AWS Management Console-> EC2 Dashboard and click Launch Configurations.

image.png

  • In the Auto Scaling page, click on Create Auto Scaling group.

image.png

  • In the create auto scaling group wizard, click create launch configuration.
  • In the next Create launch configuration page, choose the AMI Image. (It is better to create an AMI (Amazon Machine Image) for your existing ec2 instance so that auto scaling can make use of the “Similar Configurations” which already exist in your current ec2 instance.)

image.png

  • On the next page select the instance type(m1.micro or small etc..) that will be launched during scaling out.
  • The third page will request you to enter the configure details. Provide a name for your launch configuration, along with an IAM role and enable CloudWatch detailed monitoring.

image.png

  • The fourth option is to add required storage to run the instances. You can request the creation of new EBS storage volumes as part of the launch. These volumes can be deleted on termination, or they can be left around. The first option is perfect if you use the EBS volumes for temporary storage; the second would be appropriate if you generate log files on the instance and need to move them to long-term storage after the instance has been terminated.
  • The fifth option is configuring the security groups. You can use the existing security group or create a new one.
  • Finally, you can review all the settings before create launch configuration.
  • Click on Create Launch Configuration and select your keypair to access the instances.
  • The launch configuration provides Auto Scaling with all of the information needed to launch and terminate EC2 instances as part of scaling operations, but it doesn’t actually launch any instances. To do that you need to create an Auto Scaling group.
2. Create Auto Scaling Group:
  • Enter a group name, initial size, network and availability zones.

  • The second page is to configure scaling policies; you can either keep this group at its initial stage or use scaling policies to adjust the capacity of this group.

image.png

  • There are several scaling plans available with Amazon Auto Scaling option
  1. Maintain fixed number of Running EC2 instances
  2. Manual Scaling
  3. Dynamic Scaling
  4. Scheduled Scaling
  5. You can choose to select any scaling plans based on your use cases.
  • The third page will allow you to create notifications for the Auto Scaling.

image.png

  • Finally review all the options and then click create Auto Scaling Group button
  • Once the Auto Scaling Group is created you can verify the settings.

image.png

image.png

  • You can delete your auto scaling group from actions->Delete.

image.png

  • To delete the Launch configurations, you have to select the launch configurations from its page and click actions->delete.

image.png

  • You can configure Auto Scaling with other Amazon web services products like ELB, SQS, Spot instances, IAM and Cloud Watch.
Conclusion

Amazon Auto scaling will help the users to get the maximum uptime for their applications. It can provide the high availability to improve the business. Auto Scaling works along with other products of Amazon web services which will assist the user to manage the resources effectively.