Create and use AWS-Elastic load Balance (part II)-Alibaba Cloud Developer Community

The previous Douzi example demonstrates how to create a basic ELB to distribute data to different servers. Now let's go further. If the access data is too large, such as the Spring Festival Gala, such as the purchase of train tickets, how to automatically generate new servers according to the load for diversion, or automatically shut down unused servers when you are not busy. This function can be implemented by Auto Scaling.

Next, Douzi demonstrates how to create a Auto Scaling Group. It automatically adjusts the CPU Load under ELB, adds or removes Web Server, and automatically adds all automatically generated Web Server to my Elastic Load Balancer for diversion.

First, you need to create an AMI Image so that we can use this Image to automatically generate new identical Web Server.

Select Create Image on the created Lab Server

enter relevant information

created

next, we need to create Auto Scaling Configure files and Auto Scaling Group. This can be created through the management interface or through the command line. My following operations are mixed with two methods.

If you want to use the command line, download the corresponding command line tool and configure the corresponding environment variables.

For more information, see my other blog.

http://beanxyz.blog.51cto.com/5570417/1422452

after the configuration is completed, run and try it to view the Image of AMI.

This is the same as what I checked on the Management Interface

first, create a Configure configuration file. I need to specify the AMI Image, instance type, encrypted Key,Security Group,Configure file name, and Region.

If you do not know the command line, you can also operate it directly through the graphical interface.

It looks good.

Next, we will create Auto Scaling Group. Here, I will create it through the management interface. After all, this is more intuitive.

Select a configuration file

the name is aws-as-group. Pay attention to Gou Xuan load balancing. By default, the generated VMS are all in the specified ELB, and all AZ can be put into the Subnet to achieve high availability.

Then set the Policy, select the Group Size, and under what circumstances to trigger the increase or decrease operation

create an Alarm and automatically send it to my SNS Topic

for example, if the average CPU utilization exceeds 50%, a server is automatically added.

If the average CPU utilization is lower than 30%, a server is automatically deleted.

Set it up

other warning notifications

set a Tag for Auto Scaling Group to distinguish

last Review

all configurations can be modified as needed.

Because the range I set is 1-3, there must be at least one EC2 instance in the Auto Scaling Group.

Automatically create a

creating automatically

enter the IP address of the new server and run it. The LAMP works properly.

Let's take a look at ELB. It has been automatically included.

If we stop or terminate an instance in an AS instance

it automatically creates a new

finally, let's do a load test.

Click ELB and click Generate load. The corresponding server automatically performs some empty operations to forcibly increase CPU usage.

The following illustration

you can see a sharp rise in cpu usage in cloudwatch.

A new instance is automatically created if the standard is exceeded.

However, the experiment above is not very accurate, because the CPU load is generated by one of the ELB servers. We can build a new server, independent of the ELB cluster, and then use genload. The php script sends a large number of requests to the specified ELB. In this way, a more real environment can be simulated and changes caused by changes in the CPU load of ELB can be observed.

This experiment will take a long time. I will not go into details. The experiment effect is the same as before. As the CPU usage changes, EC2 instances will be automatically added or reduced.

Selected, One-Stop Store for Enterprise Applications
Support various scenarios to meet companies' needs at different stages of development

Start Building Today with a Free Trial to 50+ Products

Learn and experience the power of Alibaba Cloud.

Sign Up Now