Friday, June 12, 2026
HomeCloud ComputingNew – Attribute-Primarily based Occasion Sort Choice for EC2 Auto Scaling and...

New – Attribute-Primarily based Occasion Sort Choice for EC2 Auto Scaling and EC2 Fleet

[ad_1]

The primary AWS service I used, greater than ten years in the past, was Amazon Elastic Compute Cloud (Amazon EC2). Over time, EC2 has added a big selection of occasion sorts optimized to suit completely different use instances, with a various mixture of CPU/GPU, reminiscence, storage, and networking capability to provide the flexibility to decide on the suitable mixture of sources on your functions.

One of many key benefits of the cloud is elasticity. With EC2 Fleet, you may synchronously request capability throughout a number of occasion sorts and buy choices, launching your situations throughout a number of Availability Zones, utilizing the On-Demand, Reserved, and Spot Situations collectively. With EC2 Auto Scaling, you may routinely add or take away EC2 situations in response to circumstances you outline and add superior occasion administration capabilities reminiscent of heat swimming pools, occasion refresh, and well being checks. With these instruments, you want to manually replace your configurations to learn from the latest EC2 situations. Additionally, while you use EC2 Spot Situations to optimize your prices, it’s important that you choose a number of occasion sorts to entry the best quantity of Spot capability. Till now, there was no straightforward option to construct and preserve occasion sort configurations in a versatile manner.

At the moment, I’m completely happy to share that we’re introducing attribute-based occasion sort choice (ABS), a brand new characteristic that permits you to categorical your occasion necessities as a set of attributes, reminiscent of vCPU, reminiscence, and storage. Your necessities are translated by ABS to all matching occasion sorts, simplifying the creation and upkeep of occasion sort configurations. This additionally means that you can routinely use newer technology occasion sorts when they’re launched and entry a broader vary of capability by way of EC2 Spot Situations. EC2 Fleet and EC2 Auto Scaling choose and launch situations that match the desired attributes, eradicating the necessity to manually decide occasion sorts.

ABS is right for versatile workloads and frameworks, reminiscent of when working containers or internet fleets, processing massive knowledge, and implementing steady integration and deployment (CI/CD) tooling. When utilizing Spot Situations, as a substitute of selecting and getting into tens of occasion sorts and sizes, now you can simply use a easy attribute config to cowl all of them and embody new ones as they arrive out.

How Attribute-Primarily based Occasion Sort Choice Works
With ABS, you change the record of occasion sorts along with your occasion necessities. You’ll be able to specify occasion necessities inside a launch template or within the EC2 Fleet or EC2 Auto Scaling requests as a launch template override.

ABS works in two steps:

  • First, ABS determines a record of occasion sorts primarily based on specified attributes, AWS Area, Availability Zone, and worth.
  • Then, EC2 Auto Scaling or EC2 Fleet applies the chosen allocation technique to that record.

For Spot Situations, ABS helps the capacity-optimized and the lowest-price allocation methods.

For On-Demand Situations, ABS helps the lowest-price allocation technique. EC2 Auto Scaling or EC2 Fleet will resolve ABS attributes to a listing of occasion sorts and can launch the bottom priced occasion first to satisfy the On-Demand portion of the capability request, transferring to the subsequent lowest priced occasion if wanted.

By default ABS permits worth safety to maintain your spending underneath management. Worth safety makes ABS keep away from provisioning overly costly occasion sorts even when they occur to suit the attributes you chose and retains the costs of provisioned situations inside sure boundaries. With worth safety enabled, ABS doesn’t choose occasion sorts whose worth is above worth safety thresholds. There are two separate thresholds for Spot and On-Demand situations that you would be able to optionally customise.

Let’s see how ABS works in apply with a few examples.

Utilizing Attribute-Primarily based Occasion Sort Choice with EC2 Auto Scaling
I take advantage of the AWS Command Line Interface (CLI) with the --generate-cli-skeleton parameter to generate a file in YAML format with all of the parameters accepted by the CreateAutoScalingGroup API.

aws autoscaling create-auto-scaling-group 
    --generate-cli-skeleton yaml-input > create-asg.yaml

Within the YAML file, there’s a new InstanceRequirements part that can be utilized to override the configuration of the launch template. These are all of the attributes I can select from with some pattern values:

InstanceRequirements:
  VCpuCount:  # [REQUIRED] 
    Min: 0
    Max: 0
  MemoryMiB: # [REQUIRED] 
    Min: 0
    Max: 0
  CpuManufacturers:
  - amd
  MemoryGiBPerVCpu:
    Min: 0.0
    Max: 0.0
  ExcludedInstanceTypes:
  - ''
  InstanceGenerations:
  - earlier
  SpotMaxPricePercentageOverLowestPrice: 0
  OnDemandMaxPricePercentageOverLowestPrice: 0
  BareMetal: required  #  Legitimate values are: included, excluded, required.
  BurstablePerformance: excluded #  Legitimate values are: included, excluded, required.
  RequireHibernateSupport: true
  NetworkInterfaceCount:
    Min: 0
    Max: 0
  LocalStorage: required  #  Legitimate values are: included, excluded, required.
  LocalStorageTypes:
  - ssd
  TotalLocalStorageGB:
    Min: 0.0
    Max: 0.0
  BaselineEbsBandwidthMbps:
    Min: 0
    Max: 0
  AcceleratorTypes:
  - inference
  AcceleratorCount:
    Min: 0
    Max: 0
  AcceleratorManufacturers:
  - amazon-web-services
  AcceleratorNames:
  - a100
  AcceleratorTotalMemoryMiB:
    Min: 0
    Max: 0

As an alternative of offering a listing of overrides, every having an InstanceType attribute with a single occasion sort chosen, I can now choose the occasion sorts primarily based on my necessities. I can specify the minimal and most quantity of vCPUs, and the vary of reminiscence. Optionally, I can ask for a minimal quantity of reminiscence per vCPUs.

There are numerous extra attributes that I can choose from. For instance, I can embody, exclude, or require the usage of naked steel or burstable situations. I can add networking or storage necessities. If crucial, I can ask for GPU or FPGA accelerators, and so forth.

In my case, I ask for situations with two to 4 vCPUs and a minimum of 2048 MiB of reminiscence. Beforehand, it will have taken about 40 overrides, one for every occasion sort that meets these necessities, however with ABS, I simply need to specify three parameters within the InstanceRequirements part. That is the complete configuration file I’m going to make use of to create the Auto Scaling group:

AutoScalingGroupName: 'my-asg' # [REQUIRED] 
MixedInstancesPolicy:
  LaunchTemplate:
    LaunchTemplateSpecification:
      LaunchTemplateId: 'lt-0537239d9aef10a77'
    Overrides:
    - InstanceRequirements:
        VCpuCount: # [REQUIRED] 
          Min: 2
          Max: 4
        MemoryMiB: # [REQUIRED] 
          Min: 2048
  InstancesDistribution:
    OnDemandPercentageAboveBaseCapacity: 50
    SpotAllocationStrategy: 'capacity-optimized'
MinSize: 0 # [REQUIRED] 
MaxSize: 100 # [REQUIRED] 
DesiredCapacity: 4
VPCZoneIdentifier: 'subnet-e76a128a,subnet-e66a128b,subnet-e16a128c'

I create the Auto Scaling group passing the configuration file with the --cli-input-yaml parameter:

aws autoscaling create-auto-scaling-group 
    --cli-input-yaml file://my-create-asg.yaml

After a couple of minutes, 4 EC2 situations (equivalent to my DesiredCapacity) are working within the EC2 console. Within the record, I discover each C3 and C5a situations, spanning each time and CPU producer.

Console screenshot.

Of these situations, 50 % is On-Demand (primarily based on the OnDemandPercentageAboveBaseCapacity possibility within the InstancesDistribution part). Within the Spot Request tab of the EC2 console, I see the 2 requests:

Console screenshot.

As anticipated, all occasion sorts observe my necessities and have measurement massive. Nevertheless, I shortly understand my utility wants extra compute capability in every occasion. I replace the Auto Scaling group with the brand new necessities, asking for extra vCPUs (between 4 and 6):

aws autoscaling update-auto-scaling-group 
    --auto-scaling-group-name my-asg 
    --mixed-instances-policy '{
        "LaunchTemplate": {
            "Overrides": [
                {
                    "InstanceRequirements": {
                    "VCpuCount":{"Min": 4, "Max": 6},
                    "MemoryMiB":{"Min": 2048} }
                } ]
        } }' 

Then, I begin the occasion refresh of the Auto Scaling group:

aws autoscaling start-instance-refresh 
    --auto-scaling-group-name my-asg

EC2 Auto Scaling performs a rolling substitute of the situations primarily based on the brand new necessities. After a couple of minutes, all situations have been changed by new ones with measurement xlarge, and I’ve a mixture of C5, C5a, and M3 situations working. All earlier situations have been terminated.

Console screenshot.

Just like earlier than, two of the brand new situations are launched utilizing Spot requests. The earlier Spot requests have been closed.

Console screenshot.

How you can Preview Matching Situations with out Launching Them
To higher perceive how the brand new ABS works, I take advantage of the brand new EC2 GetInstanceTypesFromInstanceRequirements API. This API returns the record of occasion sorts matching my necessities.

First, I create the YAML parameter file:

aws ec2 get-instance-types-from-instance-requirements --generate-cli-skeleton yaml-input > necessities.yaml

I edit the file with the identical necessities I used to replace the Auto Scaling group. This time, I additionally ask to make use of present technology situations:

ArchitectureTypes:  # [REQUIRED] 
- x86_64
VirtualizationTypes: # [REQUIRED] 
- hvm
InstanceRequirements: # [REQUIRED] 
  VCpuCount:
    Min: 4
    Max: 6
  MemoryMiB:
    Min: 2048
  InstanceGenerations:
    - present

Word that right here I needed to specify the kind of structure (x86_64) and virtualization (hvm). When creating the Auto Scaling group, this data was supplied by the Amazon Machine Pictures (AMI) utilized by the launch template.

Now, let’s preview all of the occasion sorts chosen by these necessities:

aws ec2 get-instance-types-from-instance-requirements 
    --cli-input-yaml file://necessities.yaml 
    --output desk

------------------------------------------
|GetInstanceTypesFromInstanceRequirements|
+----------------------------------------+
||             InstanceTypes            ||
|+--------------------------------------+|
||             InstanceType             ||
|+--------------------------------------+|
||  c4.xlarge                           ||
||  c5.xlarge                           ||
||  c5a.xlarge                          ||
||  c5ad.xlarge                         ||
||  c5d.xlarge                          ||
||  c5n.xlarge                          ||
||  d2.xlarge                           ||
||  d3.xlarge                           ||
||  d3en.xlarge                         ||
||  g3s.xlarge                          ||
||  g4ad.xlarge                         ||
||  g4dn.xlarge                         ||
||  i3.xlarge                           ||
||  i3en.xlarge                         ||
||  inf1.xlarge                         ||
||  m4.xlarge                           ||
||  m5.xlarge                           ||
||  m5a.xlarge                          ||
||  m5ad.xlarge                         ||
||  m5d.xlarge                          ||
||  m5dn.xlarge                         ||
||  m5n.xlarge                          ||
||  m5zn.xlarge                         ||
||  m6i.xlarge                          ||
||  p2.xlarge                           ||
||  r4.xlarge                           ||
||  r5.xlarge                           ||
||  r5a.xlarge                          ||
||  r5ad.xlarge                         ||
||  r5b.xlarge                          ||
||  r5d.xlarge                          ||
||  r5dn.xlarge                         ||
||  r5n.xlarge                          ||
||  x1e.xlarge                          ||
||  z1d.xlarge                          ||
|+--------------------------------------+|

Utilizing this new EC2 API, I can shortly take a look at completely different necessities and see how they map to occasion sorts. When new occasion sorts are launched, they’re routinely added to the record in the event that they match my necessities.

Availability and Pricing
You should use attribute-based occasion sort choice (ABS) with EC2 Auto Scaling and EC2 Fleet at this time in all public and GovCloud AWS Areas, aside from these primarily based in China the place we want extra time. You’ll be able to configure ABS utilizing the AWS Command Line Interface (CLI), AWS SDKs, AWS Administration Console, and AWS CloudFormation. There is no such thing as a extra cost for utilizing ABS; you solely pay the usual EC2 pricing for the provisioned situations. For extra data on worth safety, see the EC2 Auto Scaling documentation.

This new characteristic makes it straightforward to make use of versatile occasion sort configurations as a substitute of lengthy lists of occasion sorts. On this manner, you may routinely use newer technology occasion sorts when they’re launched within the Area. Additionally, you may simply entry extra capability along with your Spot requests.

Simplify your EC2 occasion sort configurations with attribute-based occasion sort choice.

Danilo



[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments