简体   繁体   English

AWS 自动扩展组扩展事件

[英]AWS autoscale group scale in event

I am using autoscale group for adding and removing additional instances for my application.我正在使用自动缩放组为我的应用程序添加和删除其他实例。 I am using CPU Utilization as my scaling parameter and wondering what happens when an instance is running a program and the CPU Utilization comes below 65% (ie threshold value).我使用 CPU 利用率作为我的缩放参数,想知道当实例运行程序并且 CPU 利用率低于 65%(即阈值)时会发生什么。

Does it wait for the instance to finish the program or terminate the instance at that moment?它是等待实例完成程序还是在那一刻终止实例? If it terminates the instance at that moment then it might lead to data loss/data inconsistency.如果它在那个时候终止实例,那么它可能会导致数据丢失/数据不一致。

Any help would be appreciated.任何帮助,将不胜感激。

If you're looking to prevent or delay an instance during a scale in event you could take a look at lifecycle hooks .如果您希望在事件扩展期间阻止或延迟实例,您可以查看生命周期钩子

By enabling this autoscaling can send a notification that a specific instance action is about to occur (scale out or scale in).通过启用此自动缩放,可以发送特定实例操作即将发生(横向扩展或缩减)的通知 Using a combination of services (such as SNS, Lambda, SSM etc) you would be able to programmatically notify the instance that is is about to be terminated which you can then take any necessary actions.使用服务组合(例如 SNS、Lambda、SSM 等),您将能够以编程方式通知即将终止的实例,然后您可以采取任何必要的措施。

The instance termination will wait until there is a confirmation to the autoscaling group that it has been completed which will lead to it being terminated.实例终止将等到自动缩放组确认它已完成,这将导致它被终止。 Additionally a lifecycle hook will have a timeout, if no confirmation is received by the time the timeout has been exceeded then the termination will still occur.此外,生命周期钩子将有一个超时,如果在超过超时时间之前没有收到确认,那么终止仍然会发生。

I think that you are looking for termination policy我认为您正在寻找终止政策

Look at this link:看看这个链接:

https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html#default-termination-policy https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html#default-termination-policy

And in my experience, the instance will be terminated no matter what it is running根据我的经验,无论实例运行什么,它都会被终止

Does it wait for the instance to finish the program or terminate the instance at that moment.它是等待实例完成程序还是在那一刻终止实例。

Sadly, I does not wait .可悲的是,我没有等待 ASG works outside of your instances and is not concerned with any programs running on your instance. ASG 在您的实例之外工作,不关心在您的实例上运行的任何程序。

Having said that, there are few things you can do, some of which are described in:话虽如此,您可以做的事情很少,其中一些描述如下:

Generally speaking you should develop your applications to be stateless .一般来说,您应该将您的应用程序开发为无状态的。 This means the applications should be "aware" that they can be terminated at any time.这意味着应用程序应该“意识到”它们可以随时终止。 One way to achieve is by using external storage systems , such as S3 or EFS, which will persist data between terminations.一种实现方法是使用外部存储系统,例如 S3 或 EFS,它们将在终端之间持久化数据。

Other way, is to use termination protection .另一种方法是使用终止保护 In this case, the application will put its instance in this state at the beginning of processing, and then whey the calcuation finishes, the termination protection will be removed.在这种情况下,应用程序将在处理开始时将其实例放入此 state 中,然后计算完成,终止保护将被移除。

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

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