简体   繁体   English

我应该如何配置 AWS Auto-Scalling 组 mix_instances_policy 以仅允许具有多个 EC2 instance_types 的 spot_instances?

[英]How should I configure an AWS Auto-Scalling Group mixed_instances_policy to only allow for spot_instances with multiple EC2 instance_types?

I have an AWS Auto-Scalling Group that spawns (or shuts down) one EC2 machine based on the amount of messages in a specific SQS Queue.我有一个 AWS Auto-Scalling Group,它根据特定 SQS 队列中的消息量生成(或关闭)一台 EC2 机器。 That works as expected, but sometimes I get the following error:这按预期工作,但有时我会收到以下错误:

Launching a new EC2 instance.启动新的 EC2 实例。 Status Reason: Could not launch Spot Instances.状态原因:无法启动 Spot 实例。 InsufficientInstanceCapacity - There is no Spot capacity available that matches your request. InsufficientInstanceCapacity - 没有与您的请求相匹配的 Spot 容量。 Launching EC2 instance failed.启动 EC2 实例失败。

A DevOps guy I know told me to " increase the amount of spot_instance_pools to 20 and add some more instance_types ".我认识的一个 DevOps 人告诉我“将 spot_instance_pools 的数量增加到 20 并添加更多的 instance_types ”。

I did some research and found that the default number of spot_instance_pools is 2 .我做了一些研究,发现spot_instance_pools 的默认数量是 2 That same number is shown on AWS Console. AWS 控制台上显示了相同的数字。 Whenever I have this problem, I deploy a new script changing the EC instance type and it works, so both those suggestions seems like a valid ones to me.每当我遇到这个问题时,我都会部署一个更改 EC 实例类型的新脚本并且它可以工作,所以这两个建议对我来说似乎都是有效的。

The problem is that my current Terraform script does not have the enclosing mixed_instances_policy and I'm unsure how to configure it to keep only on_spot instances (since they are cheaper) and no on_demand instances.问题是我当前的 Terraform 脚本没有封闭的mixed_instances_policy ,我不确定如何配置它以仅保留on_spot实例(因为它们更便宜)而没有on_demand实例。 So far I have come up with:到目前为止,我想出了:

  mixed_instances_policy = {
    on_demand_percentage_above_base_capacity = 0
    spot_instance_pools                      = 20   
  }

Keeping the other values inside mixed_instances_policy with the defaults should suffice for me.mixed_instances_policy的其他值与默认值保持mixed_instances_policy对我来说就足够了。

But I did not understand how to configure the mixed_instances_policy launch_template .但我不明白如何配置mix_instances_policy launch_template Is it nested within mixed_instances_policy ?它是否嵌套在mixed_instances_policy Should I add a mixed_instances_policy launch_template override too?我也应该添加一个mix_instances_policy launch_template 覆盖吗? Or perhaps a launch_template_specification或者也许是一个launch_template_specification

TL;DR; TL; 博士;

How do I configure an AWS Auto-Scalling Group mixed_instances_policy to only allow for spot_instances with multiple EC2 instance_types?如何配置 AWS Auto-Scalling 组 mix_instances_policy 以仅允许具有多个 EC2 instance_types 的 spot_instances?

The on_demand_percentage_above_base_capacity = 0 line is the one you want. on_demand_percentage_above_base_capacity = 0行是您想要的。 Based on the doc you shared and the structure in the AWS doc , I'd say it probably goes inside instances_distribution That tells the ASG to launch 0% on demand (aka 100% spot).根据您共享的文档和AWS 文档中结构,我会说它可能在instances_distribution它告诉ASG 按需启动0%(也就是100% 现货)。 Within the mixed_instances_policy you need to add overrides for the instance types you're adding (weights are optional. Weight is the number of desired capacity units that instance type counts as).mixed_instances_policy您需要为要添加的实例类型添加overrides (权重是可选的。权重是实例类型计入的所需容量单位数)。

Also, the number of spot pools doesn't mater much for your use case.此外,现货池的数量对您的用例来说并不重要。 That's saying /if everything is available/ launch up to that many different spot types per AZ.也就是说/如果一切都可用/启动到每个可用区的许多不同的点类型。 Having more pools does help a bit with availability though, because if one pool becomes supply constrained, then you won't have all your instances terminated at once, but it doesn't impact being able to launch at all.不过,拥有更多池确实对可用性有所帮助,因为如果一个池变得供应受限,那么您将不会立即终止所有实例,但这根本不会影响能够启动。

Actually, if you want cheaper cost, you want the number lower.事实上,如果你想要更便宜的成本,你想要的数字更低。 Because if you have allocation strategy as 'cheapest first' then you want few pools per AZ (since its only the cheapest few pools then).因为如果您将分配策略设为“最便宜的优先”,那么您需要每个可用区的几个池(因为那时它只是最便宜的几个池)。 If there's only 1 instance type available in the AZ, its going to launch that one regardless.如果 AZ 中只有 1 个实例类型可用,则无论如何都会启动该实例类型。 So the number of overrides you select is the important part to maintain availability when launching.因此,您选择的覆盖数量是启动时保持可用性的重要部分。

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

相关问题 具有定义持续时间的现场实例和多种实例类型的 AWS Auto Scaling 组 - AWS Auto Scaling Group with defined duration spot instances and multiple instance types AWS:如何在自动扩展期间配置EC2实例 - AWS: how to configure EC2 instances during auto scale 如何使用竞价型实例数据Feed将AWS EC2竞价型实例的使用情况和价格发送到S3存储桶 - How do I send aws ec2 spot instances usage and pricing to s3 bucket using spot instance data feed 如何将AWS SQS与现货实例EC2工作者和长期运行的工作的自动扩展一起使用? - How to use AWS SQS with auto-scaling of spot instances EC2 workers and long running jobs? AWS EC2实例:启动多个实例 - AWS EC2 Instances: Launch Multiple Instance 通过AWS(EC2和竞价型实例)降低价格 - reduce price by on AWS (EC2 and spot instances) AWS IAM政策。 允许用户仅删除他们创建的ec2实例 - AWS IAM policy. Allow user to delete only the ec2 instances that they created 带有 EC2 和 Fargate 实例的 AWS 混合集群 - AWS mixed cluster with EC2 and fargate instances 如果 Spot 实例在 AWS 中不可用,我可以获取按需 EC2 实例吗 - Can I get the on-demand EC2 instances if spot instances are not available in AWS AWS EC2 实例的访问策略 - Access policy for AWS EC2 instances
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM