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.