• No results found

Getting started with Auto Scaling using AWS Management Console

In document Mastering AWS Development (Page 66-80)

terrific traffic load.

Getting started with Auto Scaling using AWS

Management Console

Using AWS Management Console, you can launch configurations and Auto Scaling using a single mouse click, and you can also bid for spot instances within this console when required.

The welcome page shows some major benefits, such as the following: • Fully automated provisioning

• Reuse instance templates • Capacity adjustment

[ 46 ]

To start with the configuration, please follow the ensuing steps carefully: 1. Creating launch configuration.

So, here we have to select the AMI and its relevant architecture, which suits our application.

You can select your desired AMI from the given options from AWS. Here, you have to give the instance type as per your requirement. For example, you can choose m1.small, t1.micro, and so on.

2. Provide configuration details:

[ 47 ]

In the preceding screenshot, you can provide information in the Advanced Details section; it lets you choose AMI's Kernel ID and Ram Disk ID and optionally fill in a User data block. User Data can be regular data to be read by an application or an executable bash script, which will be run by an EC2 instance on its start. You can provide spot instance bid details, if you want:

Spot instance bid details

3. Provide your necessary storage options in the form of the root device size, EBS volume size, and so on.

[ 48 ]

4. You can select an appropriate security group in the Configure Security

Group tab, or just add a new customized one, as shown in the following screenshot, where you restrict the SSH access to your IP while leaving the HTTP and HTTPS access open to be used from anywhere around the globe:

5. Finally, the last tab allows you to review and eventually change previous choices, if you need to:

[ 49 ]

Lastly, you have to choose the key pair to access your instances and click on Create launch configuration:

You are now done with the launch configuration for the AWS Auto Scaling service, but you have to configure the Auto Scaling group based on a schedule or policy. So, let's create an Auto Scaling group for your web application.

[ 50 ]

1. In the very first tab, you have a few choices, for example, group name, size, network, subnet, and so on, with some advanced details. In advanced details, you can call AWS Load Balancer, which will route the traffic based on policies to your scaled instances. Fill the appropriate details and click on

Next: Configure scaling policies.

2. The next tab is very important as it allows you to select between two fundamental scaling plans. Here, there are two options:

° Keep this group at its initial size, which will ensure that your group figures out a number of healthy instances equal to the initial size you mentioned. At any point of time, if an instance fails the checks, it will be replaced automatically.

[ 51 ]

° Use scaling policies to adjust the capacity of this group. You can select the CloudWatch alarm based on some policies (for example, add 1 instance if CPU usage is more than 60% or remove 2 instances if CPU usage is less than 40%) to increase or decrease the number of instances.

[ 52 ]

3. You can set policies for the minimum and maximum number of instances initiating your Auto Scaling group. You can add CloudWatch alarms easily after some time, or during the middle of deployment, but, here, we'll add the one to allow your group to increase its size, as shown in the following screenshot; you can also configure to decrease the group size.

4. You are almost done, so now it's time to configure the notifications in the

Configure Notifications tab using Simple Notification Service (SNS)

relative to your group to get updates:

[ 53 ]

5. Finally, the Review tab will be there to review the configuration, and after clicking on the Create Auto Scaling Group button, you will be redirected to a status screen showing the creation of your resources. If something fails, you're prompted to retry the single resource initiation again with correction.

So, after initiating, you can see the new scaling activity on your EC2 dashboard. And, whenever required, you can make changes in these configurations.

Here, you are done with Auto Scaling via GUI and CLI. So, now, you will see how we can configure AWS ELB with our instances to balance and route the load as per instance health check and utilization.

To start with ELB, you have to make sure that you create your ELB in the same region in which you have your EC2 instances created. I am going to list the summary steps from which you can easily understand the flow to launch ELB from your AWS Management Console. The following steps outline how to create a basic ELB in EC2-Classic:

1. Configure the listeners. 2. Configure a health check.

3. Review and create load balancer.

4. Register instances with the load balancer. 5. Verify that your ELB is created and working.

[ 54 ]

Let's look at each step one by one and see how they can be configured. 1. To configure the listeners, start your ELB wizard and click on

Create Load Balancer:

2. You will be navigated to the first tab, which is the Define Load Balancer

tab. Here, you have to set Load Balancer name, description, and, most importantly, the port numbers. So, based on your port number configuration, the ELB will route the traffic to the given port for your application.

[ 55 ]

3. After clicking on the Continue button, you will be taken to the next tab called

Configure Health Check. So, on this tab, you have to define your ping path

and port number on which the ELB will ping to check the status. If the given consecutive count for unhealthy or healthy numbers is set and your instance does not match with that, the ELB will take action like to remove or add instance back again into ELB. So, it will check your instance health based on the defined interval.

[ 56 ]

4. After clicking on the Continue button, you will be taken to Assign Security Groups to help your desired security groups communicate with your instances. Finally, the important Add EC2 Instances tab will be there on your screen in which you will add your instances that will be under ELB.

5. Finally, the Review tab will open to check the configurations made. You can see the load balancer on the load balancer wizard, and it will take some time to populate your configurations and register your EC2 instances as well. You can even configure your third-party SSL certificates with the AWS ELB at the time of creation or later. Moreover, based on your Auto Scaling, you can define your load balancer in it. At the time of creation of the Auto Scaling group, you can define your load balancer, if you want.

[ 57 ]

6. If you are configuring your Auto Scaling using CLI, you can define your ELB as an argument, so that it will automatically create a load balancer for you, and later on, you can configure the necessary route details, or you can make configurations that your ELB can communicate with EC2 instances at the same time.

Summary

In this chapter, we discussed how by using Auto Scaling and ELB services, you can set up your web application with EC2 instances and scale them based on your requirements. Using Auto Scaling and ELB, you won't face any downtime for your applications, and that's the power of Auto Scaling on AWS, which is awesome! In the next chapter, you will see the overall architecture of AWS, with a focus on breaking down the problem into discrete systems, and deciding how to physically separate those systems. You will also learn practical setup instructions for SDK and IDE toolkits, which can be used during programming with AWS services.

[ 59 ]

Storage Lifecycle

In document Mastering AWS Development (Page 66-80)