缩减规模的AWS AutoScaling-等待进程终止 [英] AWS AutoScaling, downscale - wait for processes termination

查看:49
本文介绍了缩减规模的AWS AutoScaling-等待进程终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当SQS队列较短时,我想使用AWS AutoScaling缩减一组实例.这些实例要做一些繁重的工作,有时需要5到10分钟才能完成.我希望在实例终止之前完成这项工作.

I want to use AWS AutoScaling to scaledown a group of instances when SQS queue is short. These instances do some heavy work that sometimes requires 5-10 minutes to complete. And I want this work to be completed before the instance termination.

我知道很多人应该面临同样的问题.EC2是否可以在实际终止实例之前处理AWS终止请求并完成我所有正在运行的进程?最好的方法是什么?

I know a lot of people should have faced the same problem. Is it possible on EC2 to handle the AWS termination request and complete all my running processes before the instance is actually terminated? What is the best approach to this?

推荐答案

假设您使用的是Linux,则可以创建一个预烘焙的AMI,该AMI可在连接到Auto Scaling组的Launch Config中使用.

Assuming you are using linux, you can create a pre-baked AMI that you use in your Launch Config attached to your Auto Scaling Group.

在AMI中,您可以将脚本放在/etc/init.d 下,例如/etc/init.d/servicesdown .该脚本将执行您需要关闭的所有内容,例如/usr/share/services 下的脚本.

In the AMI you can put a script under /etc/init.d say /etc/init.d/servicesdown. This script would execute anything that you need to shutdown which would be scripts under /usr/share/services for example.

有点像要点:

服务关闭

正常关闭时,它总是会被执行.

It would always get executed when doing a graceful shutdown.

然后说在Ubuntu/Debian上,您可以执行以下操作将其添加到关机序列中:

Then say on Ubuntu/Debian you would do something like this to add it to your shutdown sequence:

/usr/sbin/update-rc.d servicesdown stop 25 0 1 6 .

在CentOS/RedHat上,您可以使用 chkconfig 命令将其添加到正确的关闭运行级别.

On CentOS/RedHat you can use the chkconfig command to add it to the right shutdown runlevel.

这篇关于缩减规模的AWS AutoScaling-等待进程终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆