简体   繁体   中英

AWS Autoscaling with load balancer

I have deployed a http listener containerized app on 1 EC2 instance by creating a cluster with 1 instance and running a container task on that instance.

I am using auto scaling EC2 instances functionality with min instance as 1 and maximum instance as 4.

The issues i am facing is.

  1. Once new EC2 instances are created due to more load/ CPU utilization - the container which were deployed on first instance is not replicated on these new instances.

  2. I want to add load balancer in front of these EC2 instances as and when they gets added (or terminated). As the instances needs to be already registered to the target group - i will not be able to add the new instances as they are not yet created.

Any help on this is greatly appreciated.

You have some misunderstanding on how ALB + ASG works as a technology.

Autoscaling groups are associated with target groups. So any instance in an ASG that is associated with an ALB target group will de facto become a viable destination for the ALB - provided the instance is healthy.

I want to add load balancer in front of these EC2 instances as and
when they gets added (or terminated). As the instances needs to be
already registered to the target group - i will not be able to add
the new instances as they are not yet created.

Instances are added to the ASG, and the ASG is targetted by the target group. Create an ALB, create a target group for the ALB, create an ASG and assign it to the target group.

For your first question:

Once new EC2 instances are created due to more load/ CPU utilization -
the container which were deployed on first instance is not replicated
on these new instances.

ASGs do not clone the existing instance; they spawn a new instance from the same launch configuration as the original instance. Any manual setup you have done on the original instance will not be present on the new instance. You have two methods to address this:\\

  1. create an AMI of your first instance, and alter the launch configuration for the ASG to use this new AMI
  2. make use of Userdata to automatically configure your containerised service on instances when they boot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM