Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"EC2 Auto Scaling" workshop update with Attribute based Instance Type Selection (ABIS) #193

Merged
merged 8 commits into from
Aug 26, 2022

Conversation

ashwinikumar-sa
Copy link
Contributor

Description of changes:

  • Updated ASG configuration json - asg.json with Instance attributes instead of manual instance types list and on-demand allocation strategy to lowest-price with ABIS
  • Updated "CREATE AN EC2 AUTO SCALING GROUP" page content for ABIS and moved "manual instance types" based configuration to OPTIONAL EXERCISE

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

1. Open **asg.json** on the Cloud9 editor and review the configuration. Pay special attention at the **Overrides** and the **InstancesDistribution**. Take a look at our [docs](https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-purchase-options.html#asg-allocation-strategies) to review how InstancesDistribution and allocation strategies work. You will also notice that the **CapacityRebalance** parameter is set to true, which will proactively attempt to replace Spot Instances at elevated risk of interruption. To learn more about the Capacity Relabancing feature, take a look at the [docs](https://docs.aws.amazon.com/autoscaling/ec2/userguide/capacity-rebalance.html).
{{%expand "Help me understand the AutoScaling configuration" %}}
The **Overrides** configuration block provides EC2 AutoScaling the list of instance types your workload can run on. As Spot instances are **spare** EC2 capacity, your workloads should be flexible to run on multiple instance types and multiple availability zones; hence leveraging multiple *spot capacity pools* and making the most out of the available spare capacity. You can use the [EC2 Instance Types console](https://console.aws.amazon.com/ec2/v2/home?#InstanceTypes:) or the [ec2-instance-selector](https://github.com/aws/amazon-ec2-instance-selector) CLI tool to find suitable instance types. To adhere to best practices and maximize your chances of launching your target Spot capacity, configure a minimum of 6 different instance types across 3 Availability Zones). That would give you the ability to provision Spot capacity from 18 different capacity pools.
1. Open **asg.json** on the Cloud9 editor and review the configuration. Pay special attention at the **Overrides** and the **InstancesDistribution**. Take a look at our [docs](https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-purchase-options.html#asg-allocation-strategies) to review how InstancesDistribution and allocation strategies work. You will see in the Overrides block that instead of choosing and specifying instance types, we are specifying [instance requirements](https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_InstanceRequirements.html) as a set of instance attributes. You will use a feature called **Attribute based Instance Type Selection** that lets you express your instance requirements, as a set of attributes including vCPUs, memory, memory per vCPU, processor architecture, instance generation, GPU count and more. Your requirements are automatically translated to all matching instance types whenever EC2 Auto Scaling launches instances. This also allows Auto Scaling groups to automatically use newer generation instance types, as and when they are released. This feature eliminates the undifferentiated heavy lifting of manually selecting, specifying and maintaining instance types list in the Overrides configuration block. To learn more about Attribute based Instance Type Selection, please take a look at the [docs](https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-asg-instance-type-requirements.html) and this [blog](https://aws.amazon.com/blogs/aws/new-attribute-based-instance-type-selection-for-ec2-auto-scaling-and-ec2-fleet/). You will also notice that the **CapacityRebalance** parameter is set to true, which will proactively attempt to replace Spot Instances at elevated risk of interruption. To learn more about the Capacity Relabancing feature, take a look at the [docs](https://docs.aws.amazon.com/autoscaling/ec2/userguide/capacity-rebalance.html).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks adding the ABIS section, can you please add a screenshot of ABIS and break the paragraph in smaller sections. This will make is easier to read.


Then, the *InstancesDistribution* configuration block determines how EC2 Auto Scaling picks the instance types to use, while at the same time it keeps a balanced number of EC2 instances per Availability Zone.
{{%expand "Help me understand Auto Scaling group configuration with Attribute based Instance Type Selection" %}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take this out of expand as it is important to understand these parameters. Can you merge above # 1 section and this expand section and make it simpler to understand the whole thing? Also feel free to use screenshots to make it easier to understand.

* Instances which have minimum vCPU to Memory ratio 1:2 and maximum vCPU to Memory ratio of 1:8
* Instances with CPU Architecture of Intel and AMD and no GPU Instances
* Instances that belong to current generation
* Excluding Instance families of type: d*,h*,i*,x* and z*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why are we excluding these instances?


* The **prioritized** allocation strategy for on-demand instances makes AutoScaling try to launch the first instance type of your list and skip to the next instance type if for any reason it's unable to launch it (e.g. temporary unavailability of capacity). This is particularly useful if you have [Reserved Instances](https://aws.amazon.com/ec2/pricing/reserved-instances/) or [Savings Plans](https://aws.amazon.com/savingsplans/) for your baseline capacity, so Auto Scaling launches the instance type matching your reservations.
You can see that above criteria is configured in the *InstanceRequirements* block of the *Overrides* configuration in *asg.json*. Then, the *InstancesDistribution* configuration block determines how EC2 Auto Scaling picks the instance types to use, while at the same time it keeps a balanced number of EC2 instances per Availability Zone.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above looks a repeat of # 1. Let's simplify all this by avoiding repeated information.

* **OnDemandBaseCapacity** is set to 2, meaning the first two EC2 instances launched by EC2 AutoScaling will be on-demand.
* **OnDemandPercentageAboveBaseCapacity** is set to 0 so all the additional instances will be launched as Spot Instances
* **SpotAllocationStrategy** is capacity-optimized, which instructs AutoScaling to pick the optimal instance type on each Availability Zone based on launch time availability of spare capacity for your instance type selection.
* **SpotAllocationStrategy** is **capacity-optimized**, which instructs Auto Scaling to pick the optimal instance type on each Availability Zone based on launch time availability of spare capacity for your instance type selection. With *Attribute based Instance Type Selection*, your Spot allocation strategy must be either *capacity-optimized* or *lowest-price* and to use the *capacity-optimized-prioritized* allocation strategy, you must manually add and prioritize your instance types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by this line? "you must manually add and prioritize your instance types"

Now that you have deployed an EC2 Auto Scaling group with Mixed Instance Types and Purchase options, take some time to go through the different configurations in the [console](https://console.aws.amazon.com/ec2autoscaling/home?#/). Click on the **myEC2Workshop** Auto Scaling group and go to the *Instance type requirements* section and click *Edit* button and scroll down to *Preview matching instance types*. Expand to see list of instance types based on your selected instance attributes. Try to edit the instance requirements configured on the Auto Scaling group and see how this preview list changes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section will cause confusion and it's also error prone as in previous section you have already created ASG with name myEC2Workshop and ABIS. Now in this section you are creating another ASG with manually selecting instances. Let's discuss we can keep only ABIS.

**Optionally**, you can use the [EC2 Instance Types console](https://console.aws.amazon.com/ec2/v2/home?#InstanceTypes:) or the [ec2-instance-selector](https://github.com/aws/amazon-ec2-instance-selector) CLI tool to find suitable instance types. To adhere to best practices, minimize Spot interruptions and maximize your chances of launching your target Spot capacity, configure as many different instance types as possible. EC2 Auto Scaling allows you to specify up to 40 different instance types. For the purpose of this workshop, we will use a minimum of 12 different instance types across 3 Availability Zones. That would give you the ability to provision Spot capacity from 36 different capacity pools.

If you have [Reserved Instances](https://aws.amazon.com/ec2/pricing/reserved-instances/) or [Savings Plans](https://aws.amazon.com/savingsplans/) for your baseline capacity, you can use the **prioritized** allocation strategy for on-demand instances to make AutoScaling try to launch the first instance type of your list. It will skip to the next instance type if for any reason it's unable to launch first one (e.g. temporary unavailability of capacity).
Copy link
Contributor

@jagpk jagpk Jun 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it impact Savings plan? It is relevant for only RIs/EC2 Savings plans.

Copy link
Contributor

@jagpk jagpk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, review comments have been incorporated. Thanks for you contribution @ashwinikumar-sa

@jagpk jagpk merged commit 3864445 into awslabs:master Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants