如何自动 resize/scale amazon aws ec2 实例
how to auto resize/scale amazon aws ec2 instance
目前在 t2.micro 上,我读到亚马逊允许自动缩放选项以允许服务器根据完美的流量 expand/shrink。
所以我的问题是:
what exactly should i do in-order to enable the auto scaling/resizing
of the server when needed or when the traffic start to spike ?
is there an option to allow changing the instance type automatically ?
auto scaling i believe means adding more instances and balance the load in between them, so does this mean i need to have a background about load balancing and all that jargon that comes with it or does amazon take care of that automatically ?
我对整个服务器maintenance/provisioning都是全新的,所以请尽量解释得简单些。这也是我选择亚马逊的唯一原因,因为它提供的自动化功能,但遗憾的是,他们的文档非常复杂,很多事情都可能出错。
使用 EC2 的自动缩放假定 "horizontal" 缩放,向自动缩放组添加更多实例
"vertical" 自动增加单个实例大小的扩展没有很好用的标准模式。
为了有效地理解和为您的应用程序使用自动缩放,是的,您 "need to have a background about load balancing and all that jargon that comes with it"。参见 http://docs.aws.amazon.com/autoscaling/latest/userguide/GettingStartedTutorial.html
我假设您使用的是 AWS 管理控制台。使用命令行界面或 AWS CloudFormation 也可以执行这些操作。
要调整一个实例,您必须停止它然后转到操作>实例设置>更改实例类型
如您所见,此操作不是自动的。在 AWS 中,您不会自动缩放一个实例,而是一个自动缩放组,它是一组实例。所以根据你的memory/cpu使用情况,你可以自动启动新实例(但不会增加当前实例的大小)
要创建 autoscaling 组,请转到 EC2 菜单中的 Auto Scaling Groups:
要创建自动缩放组,您需要先创建一个启动配置,它描述了您要自动缩放的实例的属性。然后,您将能够根据 Cloudwatch 警报(CPU 使用情况、实例状态...)定义扩展策略:
如果您想扩展您的实例并且不介意正常运行时间,我可以建议这个解决方法。
TL;DR:在触发特定警报时将 AWS CloudWatch 上的警报设置为 "ping" SNS(即 CPU,RAM > %)并设置 Skeddly 操作以自动扩展您的实例当 SNS 端点被 ping 时。
详情:
订阅 Skeddly,一项在 AWS 上自动执行操作的服务。
如果你不经常使用它是免费的;
设置一个"Change EC2 Instances"动作并激活SNS功能,
然后复制 SNS 端点 link; screenshot
请务必明确定义受操作影响的实例!
继续 AWS Simple Notification Service 仪表板并创建一个新的
"topic",然后 select 它并从中选择 "subscribe to topic"
操作菜单;
你可以在这里粘贴Skeddly提供的SNS端点,然后稍等
直到确认订阅(需要一段时间);
现在转移到 AWS CloudWatch 并为任何指标设置警报
您发现对您的实例有意义 up/downscaling,即 CPU >= 90%
1 天;
为每个警报添加通知 select之前 "topic"
在 SNS 上定义。
大功告成!
目前在 t2.micro 上,我读到亚马逊允许自动缩放选项以允许服务器根据完美的流量 expand/shrink。
所以我的问题是:
what exactly should i do in-order to enable the auto scaling/resizing of the server when needed or when the traffic start to spike ?
is there an option to allow changing the instance type automatically ?
auto scaling i believe means adding more instances and balance the load in between them, so does this mean i need to have a background about load balancing and all that jargon that comes with it or does amazon take care of that automatically ?
我对整个服务器maintenance/provisioning都是全新的,所以请尽量解释得简单些。这也是我选择亚马逊的唯一原因,因为它提供的自动化功能,但遗憾的是,他们的文档非常复杂,很多事情都可能出错。
使用 EC2 的自动缩放假定 "horizontal" 缩放,向自动缩放组添加更多实例
"vertical" 自动增加单个实例大小的扩展没有很好用的标准模式。
为了有效地理解和为您的应用程序使用自动缩放,是的,您 "need to have a background about load balancing and all that jargon that comes with it"。参见 http://docs.aws.amazon.com/autoscaling/latest/userguide/GettingStartedTutorial.html
我假设您使用的是 AWS 管理控制台。使用命令行界面或 AWS CloudFormation 也可以执行这些操作。
要调整一个实例,您必须停止它然后转到操作>实例设置>更改实例类型
如您所见,此操作不是自动的。在 AWS 中,您不会自动缩放一个实例,而是一个自动缩放组,它是一组实例。所以根据你的memory/cpu使用情况,你可以自动启动新实例(但不会增加当前实例的大小)
要创建 autoscaling 组,请转到 EC2 菜单中的 Auto Scaling Groups:
要创建自动缩放组,您需要先创建一个启动配置,它描述了您要自动缩放的实例的属性。然后,您将能够根据 Cloudwatch 警报(CPU 使用情况、实例状态...)定义扩展策略:
如果您想扩展您的实例并且不介意正常运行时间,我可以建议这个解决方法。
TL;DR:在触发特定警报时将 AWS CloudWatch 上的警报设置为 "ping" SNS(即 CPU,RAM > %)并设置 Skeddly 操作以自动扩展您的实例当 SNS 端点被 ping 时。
详情:
订阅 Skeddly,一项在 AWS 上自动执行操作的服务。 如果你不经常使用它是免费的;
设置一个"Change EC2 Instances"动作并激活SNS功能, 然后复制 SNS 端点 link; screenshot
请务必明确定义受操作影响的实例!
继续 AWS Simple Notification Service 仪表板并创建一个新的 "topic",然后 select 它并从中选择 "subscribe to topic" 操作菜单;
你可以在这里粘贴Skeddly提供的SNS端点,然后稍等 直到确认订阅(需要一段时间);
现在转移到 AWS CloudWatch 并为任何指标设置警报 您发现对您的实例有意义 up/downscaling,即 CPU >= 90% 1 天;
为每个警报添加通知 select之前 "topic" 在 SNS 上定义。
大功告成!