通过Auto Scaling管理Amazon EC2中应用程序的代码更改的最佳方法 [英] Best way to manage code changes for application in Amazon EC2 with Auto Scaling

查看:88
本文介绍了通过Auto Scaling管理Amazon EC2中应用程序的代码更改的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS的Auto Scaling中有多个实例在负载均衡器后面运行。

I have multiple instances running behind Load balancer with Auto Scaling in AWS.

现在,如果我必须对这些实例和任何新实例进行一些代码更改,可能由于自动缩放策略而启动,执行此操作的最佳方法是什么?

Now, if I have to push some code changes to these instances and any new instances that might launch because of auto scaling policy, what's the best way to do this?

我知道的唯一方法是,使用最新代码创建新的AMI,然后进行修改自动缩放策略以使用此新AMI,然后终止现有实例。但这可能会导致更长的停机时间,而且我不确定整个过程是否可以自动化。

The only way I am aware of is, to create a new AMI with latest code, modify the auto scaling policy to use this new AMI and then terminate the existing instances. But this might involve a longer downtime and I am not sure whether the whole process can be automated.

任何朝着这个方向发展的指针都会受到赞赏。

Any pointers in this direction will be highly appreciated.

推荐答案

我进行代码更改的方法是拥有一个主服务器,在该服务器上进行代码编辑。然后通过cron作业通过ssh进行伸缩的所有从属服务器,以使所有文件保持最新状态。所有服务器每30分钟同步一次-随机间隔几秒钟,以防止在同一秒内访问它。 (请注意,我将主服务器保留在负载均衡器之外,因此用户始终会收到相同的代码。类似地,当我决定发布我的代码更改时,我会从测试服务器到主服务器执行rsync。

The way I do my code changes is to have a master server which I edit on the code on. All the slave servers which scale then rsync via ssh by a cron job to bring all the files up to date. All the servers sync every 30 minutes +- a few random seconds to keep from accessing it at the exact same second. (note I leave the Master off of the load balancer so users always have the same code being sent to them. Similarly, when I decide to publish my code changes, I do an rsync from my test server to my master server.

使用这种方法,您只需要在启动中放入sync命令,就不必担心从属映像上的代码状态如何了。在启动后保持最新状态。

Using this approach, you merely have to put the sync command in the start-up and you don't have to worry about what the code state was on the slave image as it will be up to date after it boots.

编辑:
我们现在已停止使用此方法,并开始使用针对此特定需求的新服务AWS CodeDeploy目的:

We have stopped using this method now and started using the new service AWS CodeDeploy which is made for this exact purpose:

http://aws.amazon.com / codedeploy /

希望这会有所帮助。

这篇关于通过Auto Scaling管理Amazon EC2中应用程序的代码更改的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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