Matching Tasks to Fleets

Learn how the Batch service automatically matches tasks to the most appropriate fleets using task profiles and assignment policies, streamlining hardware selection and job scheduling.

When you run jobs in Batch service, your tasks need the right hardware to run efficiently. Fleets are pools of compute resources that you set up in your batch context. Fleets are groups of machines with specific CPU, memory, and disk configurations. You don't need to match every task to a specific machine or fleet. Instead, the Batch service uses task profiles and assignment policies to find the best fit for each task.

Using Task Profiles to Define Hardware Requirements

Instead of specifying hardware details for every task, you can use task profiles in Batch. A task profile is a reusable object that defines the minimum hardware requirements for a task, such as OCPUs, memory, and disk space. For example, you might create a task profile with 4 OCPUs and 16 GB RAM, and another for heavier workloads.

When you submit a task, assign it a task profile. This tells Batch what kind of hardware to allocate, without requiring you to specify a particular fleet.

Assigning Tasks to Fleets with Assignment Policies

Batch relies on assignment policies to assign tasks to fleets. Assignment policies are rules that determine how Batch chooses from available fleets for each task.

Assignment policies work in two ways:

  • Best-fit Policy: Batch selects the smallest available fleet that meets your task's requirements. If no resources are available in that fleet, the task waits until a slot is available. Tasks aren't moved to larger fleets.
  • Flex-fit Policy: If you want more flexibility, Flex-fit allows Batch to assign your task to larger fleets if the smallest one is full. You can set a threshold to control how much larger the alternative fleet can be. If you don't set a limit, Batch uses any available fleet to run your tasks quickly.

If you don't specify a policy, Batch uses Flex-fit with no limits by default.

Selecting Fleets

Batch sorts fleets based on their hardware profiles, including CPU, memory, and then disk. This order ensures that Best-fit and Flex-fit always prioritize smaller, more cost-effective fleets before moving to larger ones.

For example, if you have three fleets with the following configurations:
  • Small fleet: 4 OCPUs, 8 GB RAM per machine
  • Medium fleet: 10 OCPUs, 32 GB RAM
  • Large fleet: 30 OCPUs, 128 GB RAM
If you submit a batch job where each task needs 4 OCPUs and 8 GB RAM:
  • Best-fit: Each task is assigned to the small fleet if space is available.
  • Flex-fit: If the small fleet is full, tasks are assigned to the medium or large fleet as needed (within any threshold you set).

This scheduling is automatic, and there's no need to manage where each task runs.

Batch automatically matches tasks to the most suitable fleets based on the profiles and policies you select. For more information, see Fleets section in Creating a Batch Context topic.

Disk Requirements and Fleet Eligibility

In API requests, diskSizeInGBs is the fleet configuration property that specifies the size, in GB, of the boot volume for each fleet node.

When diskSizeInGBs is omitted or set to null when you create a fleet, Batch derives the boot-volume size from the selected image and applicable minimum requirements. The derived size can change as images and requirements change. To guarantee a specific node boot-volume size, set diskSizeInGBs explicitly.

CPU fleets require a boot-volume size of at least 75 GiB. GPU fleets require a boot-volume size of at least 100 GiB. Fleet provisioning fails if you specify a size below the applicable minimum.

A task is eligible for a fleet only when the task profile's minDiskSizeInGBs doesn't exceed the fleet's resolved diskSizeInGBs. This comparison uses the fleet node boot-volume size.

For example, an automatically sized CPU fleet currently resolves to 75 GiB. A task that requires 75 GiB can be scheduled on that fleet. A task that requires 200 GiB can't be scheduled on that fleet. The 75 GiB value is a current resolved value, not a permanent CPU default.

minDiskSizeInGBs is a scheduling requirement. It doesn't guarantee that the same capacity is available in the task container file system. For information about configuring the task requirement, see Creating a Task Profile.

When No Fleet Is Eligible

If no fleet in the batch context meets a task profile's resource requirements, Batch can't schedule the task.

For example, if a task profile requires 200 GiB and the largest eligible fleet has a resolved boot-volume size of 75 GiB, no fleet meets the task profile's disk requirement. Review the task profile requirement and fleet configuration, then either reduce the task requirement or configure a fleet with sufficient capacity.