---
title: "Scheduler"
url: https://www.daytona.com/compute-glossary/infrastructure/scheduler
---

# Scheduler

Part of the [Compute Glossary](https://www.daytona.com/compute-glossary.md), section [Infrastructure](https://www.daytona.com/compute-glossary/infrastructure.md).

A scheduler is the component of a cluster that picks a host for each [workload](https://www.daytona.com/compute-glossary/foundations/workload.md) it receives. It weighs what the workload needs against what each host has free, and its choice usually holds for the whole life of the workload. A scheduler that decides badly leaves some hosts idle and others overloaded, even when the cluster as a whole has room. Most place one workload at a time, without knowing what requests will come next.

A cluster scheduler works one level above the scheduler inside a [kernel](https://www.daytona.com/compute-glossary/kernel/kernel.md). The kernel decides which process runs on a [CPU core](https://www.daytona.com/compute-glossary/hardware/cpu-core.md) for the next few milliseconds, while the cluster scheduler decides which [server](https://www.daytona.com/compute-glossary/hardware/server.md) a workload lives on. The two work on very different time scales, which is why they are separate programs. A virtual machine placed by the cluster scheduler still depends on the kernel of its host to decide when its vCPUs run.

The scheduler takes requests from the [control plane](https://www.daytona.com/compute-glossary/infrastructure/control-plane.md) and hands each one to a host. A good placement keeps hosts busy without overloading them, and keeps a single failure from taking down too much at once. The handoff usually happens by writing the chosen host into the stored state, which an agent on that host watches. If the host then refuses or fails, the workload goes back to the scheduler for another try.

## Filtering and scoring

Filtering and scoring are the two steps in which most schedulers place a workload. Filtering removes every host that cannot run it at all, and scoring ranks the hosts that remain and picks the best one. Filtering is cheap and cuts the field quickly, so the slower scoring step runs on fewer hosts. If no host passes the filter, the workload waits until one frees up, or the request fails.

A host fails the filter when it lacks the free [memory](https://www.daytona.com/compute-glossary/hardware/memory.md) or processor capacity the workload asks for. It also fails when it has the wrong [instruction set architecture](https://www.daytona.com/compute-glossary/hardware/cpu-architecture.md) for the compiled program, or no free [GPU](https://www.daytona.com/compute-glossary/hardware/gpu.md). The check counts what workloads reserved, not what they use right now, so an idle host can still be full. A host marked for maintenance or reporting a fault is filtered out as well.

Scoring reflects whatever the operator values most, such as low cost or high availability. Each host gets a number from a set of weighted rules, and the scheduler sends the workload to the host with the highest. A rule might favor hosts that already cache the image of the workload, or hosts with the most free memory. Small changes to the weights can shift the layout of a whole cluster.

## Affinity and anti-affinity

Affinity and anti-affinity are constraints that place a workload near something else or away from it. Affinity might ask for the same host as a database, or the same zone as the storage the workload reads. Being close cuts the latency between the two, and can avoid charges for traffic between zones. Affinity rules usually name a group of workloads, not a single machine, so they still hold when hosts come and go.

Anti-affinity asks for the opposite, such as two replicas of one service on different hosts, so that one failure does not take down both. Labels on hosts work in a similar way, letting a workload require a host that has a feature it needs. Spreading copies across zones takes the same idea one level up, protecting against the loss of a whole datacenter. Labels typically mark hardware such as a GPU model or a faster disk.

Some of these rules are hard and fail the placement when they cannot be met. Others are preferences that only change the score, so the workload still runs somewhere when no host meets them all. Hard rules are easy to overuse, and a cluster full of them can leave workloads waiting while hosts sit half empty. Preferences give the scheduler room to fall back when the cluster is busy.

## Bin packing and spreading

Bin packing and spreading are the two goals that scoring trades between. Bin packing fills hosts as tightly as possible before using new ones, and spreading places work across as many hosts and zones as possible. The name comes from the classic problem of fitting items of different sizes into the fewest bins. Finding the best fit exactly is too slow for a busy cluster, so schedulers use quick rules that come close.

Packing runs fewer machines and leaves whole hosts free for large requests. Spreading means a single failure touches fewer workloads, and neighbors compete less for shared caches and network. Free hosts can also be powered down or handed back to a provider, which saves money directly. Spreading leaves every host partly used, so a large request may find no single host with enough room.

Real schedulers mix the two, for example spreading replicas of one service while packing everything else. Large ones also sample a subset of hosts instead of checking every one, because the decision time adds to each start. Sampling trades a slightly worse placement for a much faster decision. Some schedulers also move running work later to fix a layout that has drifted, though moving interrupts it.

## Placing sandboxes

Placing [sandboxes](https://www.daytona.com/compute-glossary/sandboxes/sandbox.md) is the scheduler's choice of a host for each new sandbox, made through the same filtering and scoring as for any workload. A sandbox asks for processors, memory and disk, and sometimes a GPU or a particular CPU type. The scheduler finds the hosts that fit and scores them before the sandbox can boot. The decision is made for every sandbox, so its speed matters more than for long-running services.

The time spent placing a sandbox adds directly to its start time. A scheduler that checks every host in a large fleet can take longer than the boot itself. Platforms that start many short-lived sandboxes therefore keep placement fast, by sampling hosts or by tracking which hosts have room. Some send a request to a host that already holds its image or [snapshot](https://www.daytona.com/compute-glossary/sandboxes/snapshot.md), which skips a download.

Placement also decides which sandboxes share a host, and so who their neighbors are. Spreading one customer's sandboxes across hosts limits what a single failure takes down. Packing them saves hosts but lets a busy sandbox slow the others nearby. Some platforms keep the sandboxes of different customers on separate hosts, adding a layer of [isolation](https://www.daytona.com/compute-glossary/sandboxes/isolation.md) beyond the boundary of each machine.

## Related terms

- [Sandbox](https://www.daytona.com/compute-glossary/sandboxes/sandbox.md)
- [Control plane](https://www.daytona.com/compute-glossary/infrastructure/control-plane.md)
- [Overcommit](https://www.daytona.com/compute-glossary/infrastructure/overcommit.md)
- [Workload](https://www.daytona.com/compute-glossary/foundations/workload.md)
- [CPU architecture](https://www.daytona.com/compute-glossary/hardware/cpu-architecture.md)
- [GPU](https://www.daytona.com/compute-glossary/hardware/gpu.md)
