Enum AllocationStrategy

java.lang.Object
java.lang.Enum<AllocationStrategy>
software.amazon.awscdk.services.batch.AllocationStrategy
All Implemented Interfaces:
Serializable, Comparable<AllocationStrategy>, java.lang.constant.Constable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-22T02:23:57.579Z") @Stability(Stable) public enum AllocationStrategy extends Enum<AllocationStrategy>
Determines how this compute environment chooses instances to spawn.

Example:

 IVpc vpc;
 ManagedEc2EcsComputeEnvironment computeEnv = ManagedEc2EcsComputeEnvironment.Builder.create(this, "myEc2ComputeEnv")
         .vpc(vpc)
         .allocationStrategy(AllocationStrategy.BEST_FIT)
         .build();
 

See Also:
  • Enum Constant Details

    • BEST_FIT

      @Stability(Stable) public static final AllocationStrategy BEST_FIT
      Batch chooses the lowest-cost instance type that fits all the jobs in the queue.

      If instances of that type are not available, the queue will not choose a new type; instead, it will wait for the instance to become available. This can stall your Queue, with your compute environment only using part of its max capacity (or none at all) until the BEST_FIT instance becomes available. This allocation strategy keeps costs lower but can limit scaling. BEST_FIT isn't supported when updating compute environments

    • BEST_FIT_PROGRESSIVE

      @Stability(Stable) public static final AllocationStrategy BEST_FIT_PROGRESSIVE
      This is the default Allocation Strategy if spot is false or unspecified.

      This strategy will examine the Jobs in the queue and choose whichever instance type meets the requirements of the jobs in the queue and with the lowest cost per vCPU, just as BEST_FIT. However, if not all of the capacity can be filled with this instance type, it will choose a new next-best instance type to run any jobs that couldn’t fit into the BEST_FIT capacity. To make the most use of this allocation strategy, it is recommended to use as many instance classes as is feasible for your workload.

    • SPOT_CAPACITY_OPTIMIZED

      @Stability(Stable) public static final AllocationStrategy SPOT_CAPACITY_OPTIMIZED
      If your workflow tolerates interruptions, you should enable spot on your ComputeEnvironment and use SPOT_CAPACITY_OPTIMIZED (this is the default if spot is enabled).

      This will tell Batch to choose the instance types from the ones you’ve specified that have the most spot capacity available to minimize the chance of interruption. To get the most benefit from your spot instances, you should allow Batch to choose from as many different instance types as possible.

    • SPOT_PRICE_CAPACITY_OPTIMIZED

      @Stability(Stable) public static final AllocationStrategy SPOT_PRICE_CAPACITY_OPTIMIZED
      The price and capacity optimized allocation strategy looks at both price and capacity to select the Spot Instance pools that are the least likely to be interrupted and have the lowest possible price.

      The Batch team recommends this over SPOT_CAPACITY_OPTIMIZED in most instances.

  • Method Details

    • values

      public static AllocationStrategy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static AllocationStrategy valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null