简体   繁体   English

使用负载均衡器进行AWS自动扩展

[英]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. 通过在1个EC2实例上创建一个集群并在该实例上运行容器任务,我在1个EC2实例上部署了一个HTTP侦听器容器化的应用程序。

I am using auto scaling EC2 instances functionality with min instance as 1 and maximum instance as 4. 我正在使用自动缩放EC2实例功能,最小实例为1,最大实例为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. 一旦由于更多的负载/ CPU利用率而创建了新的EC2实例-在第一个实例上部署的容器就不会在这些新实例上复制。

  2. I want to add load balancer in front of these EC2 instances as and when they gets added (or terminated). 我想在添加(或终止)这些EC2实例之前在它们之前添加负载均衡器。 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. 您对ALB + ASG作为一种技术的工作方式有一些误解。

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. 因此,只要实例运行状况良好,ASG中与ALB目标组相关联的任何实例实际上都会成为ALB的可行目的地。

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. 将实例添加到ASG,并且目标组将ASG作为目标。 Create an ALB, create a target group for the ALB, create an ASG and assign it to the target group. 创建一个ALB,为该ALB创建一个目标组,创建一个ASG并将其分配给目标组。

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; ASG不克隆现有实例。 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 创建第一个实例的AMI,并更改ASG的启动配置以使用此新AMI
  2. make use of Userdata to automatically configure your containerised service on instances when they boot. 在实例启动时,利用Userdata自动在实例上配置您的容器化服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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