> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How the Scheduler Places Work

> Explains how Nomad schedules work by creating evaluations, producing plans the leader accepts, filtering then scoring nodes, using bin packing and rescheduling allocations after node failures.

Who decided on Machine 2?

That placement is the result of a short chain of steps Nomad follows for every meaningful change. Understanding that chain makes it much easier to debug why work ended up where it did.

It starts the moment Maya submits her job. Nomad compares the job specification with the cluster’s current state. If there’s any difference, Nomad creates an evaluation.

An evaluation is simply a question Nomad asks itself: something changed, so what (if anything) needs to happen now? Every meaningful event creates an evaluation — a job submission, a node going offline, a task failure, or a configuration change will trigger one.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/evaluation-decision-not-coin-toss.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=83e76cd056263c02f3664a95e79881ef" alt="A presentation slide showing icons for events—“a job is submitted,” “a machine goes offline,” and “a task dies”—above rows of server/Docker boxes labeled box-1 through box-4. The header reads “An Evaluation Is a Question” with the emphasized message “A decision, not a coin toss.”" width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/evaluation-decision-not-coin-toss.jpg" />
</Frame>

That evaluation is delivered to a scheduler process. The scheduler reasons about the current cluster state and produces a plan — a proposal such as “start these tasks on that node” or “stop these tasks.” Plans are forwarded to the servers, but only the cluster leader may accept a plan. The leader’s acceptance is the single source of truth for allocation changes; this prevents conflicting promises for the same scarce resources (for example, the last gigabyte of memory on Machine 2).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/only-leader-may-say-yes-flow.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=a78a19bc86f8a354165b2c92cb565e0c" alt="A presentation slide showing a decision flow with icons for evaluation, plan, and a leader (scale) and the caption &#x22;Only the leader may say yes.&#x22; Below are four labeled boxes (box-1 to box-4) with server/container icons." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/only-leader-may-say-yes-flow.jpg" />
</Frame>

When the leader accepts a plan, Nomad creates an allocation. An allocation is the record that ties a set of tasks to a specific machine. The job is what Maya requested; the allocation is what actually runs on a node.

<Callout icon="lightbulb" color="#1CB2FE">
  An evaluation → scheduler plan → leader acceptance → allocation. The leader’s acceptance is what makes a plan real.
</Callout>

Two phases determine which node the scheduler chooses: filter, then score.

* Filter: eliminate nodes that cannot run the task (hard requirements).
* Score: rank the remaining eligible nodes and pick the highest-scoring one.

Only nodes that pass all filters are eligible; those survivors are then scored and the highest-scoring node wins.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/filter-then-score-job-promise-containers.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=29d132a1f5bda51fc685e3220cd3b468" alt="A presentation slide titled &#x22;Filter, Then Score&#x22; with magnifying-glass and gauge icons, short error notes (&#x22;not in dc1 · out&#x22;, &#x22;not enough memory · out&#x22;) and the phrase &#x22;The job is the promise.&#x22; Below are four blue container/ship icons above server illustrations labeled box-1 through box-4." width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/filter-then-score-job-promise-containers.jpg" />
</Frame>

Common filter examples:

| Filter type | What it checks | Effect |
| - | - | - |
| Datacenter | `datacenters = ["dc1"]` | Excludes nodes in other datacenters |
| Resources | CPU / memory / disk availability | Excludes nodes without enough free resources |
| Attributes / Constraints | `constraint` blocks for OS, disk type, etc. | Excludes nodes not matching the required attribute |

A common surprise is that Nomad does not try to spread work evenly by default. Its default placement strategy is bin packing: prefer to fill up nodes before using additional ones. Think of it like packing boxes into vans — you fill one van, then the next, rather than putting a single box in each van.

Bin packing concentrates workloads so some machines become fully utilized while others remain empty. Those empty machines are purposeful: you can power them down to save cost or reserve them for large jobs that require a lot of capacity in one place.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/l4I9ipyyKXTd2i-D/images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/bin-packing-icons-search-capacity-scoring.jpg?fit=max&auto=format&n=l4I9ipyyKXTd2i-D&q=85&s=e32bfa940a5449900eda7a6a663fb2a1" alt="A presentation slide about bin packing with icons for search, capacity, and scoring and text like &#x22;not in dc1 · out&#x22;, &#x22;not enough memory · out&#x22;, and &#x22;what survives is scored.&#x22; At the bottom are server and container icons labeled box-1 through box-4 and a headline on the right reading &#x22;Those numbers earn their keep.&#x22;" width="1920" height="1080" data-path="images/Learn-By-Doing-HashiCorp-Nomad/Foundations-From-SSH-to-Scheduler/How-the-Scheduler-Places-Work/bin-packing-icons-search-capacity-scoring.jpg" />
</Frame>

If Maya needs a specific property from the node (for example, only run on Linux or only on machines with NVMe disks), she can add a `constraint` block to the job. Constraints are hard filters — they remove nodes that don’t meet the condition rather than merely influencing scoring.

Example: rescheduling after a node failure
Maya deliberately shuts down Machine 2. Nomad detects the node is no longer answering and creates an evaluation. The scheduler produces a replacement plan for the tasks that were on Machine 2, the leader accepts it, and a new allocation is created on Machine 4. The API resumes without manual intervention.

```bash theme={null}
$ nomad node status
ID     CLASS   STATUS
box-1  host    ready
box-2  host    down
box-3  host    ready
box-4  host    ready

# The allocation that ran on box-2 is rescheduled -> box-4
```

Note that Maya’s job file still declares “run one copy of the API.” What changed is which machine satisfies that promise — Nomad rebuilt the single copy on another node, so Maya doesn’t need to know or care where it runs.

<Callout icon="warning" color="#FF6B6B">
  Running a single instance limits availability. If that instance’s node fails, the API is unavailable until Nomad rebuilds it elsewhere. Consider running multiple replicas for higher availability and capacity.
</Callout>

Quick reference: events that trigger an evaluation

| Event | Example |
| - | - |
| Job lifecycle | Job submission, update, or stop |
| Node state | Node goes `down`, is drained, or rejoins |
| Task lifecycle | Task exits, crashes, or is evicted |
| Cluster changes | Scheduler configuration or server leader change |

Further reading and references

* Nomad scheduler concepts: [https://www.nomadproject.io/docs/concepts/scheduling](https://www.nomadproject.io/docs/concepts/scheduling)
* Nomad job specification (constraints and resources): [https://www.nomadproject.io/docs/job-specification](https://www.nomadproject.io/docs/job-specification)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/learn-by-doing-hashicorp-nomad/module/bbb9e697-2e59-4591-b750-678ef12293d3/lesson/78a2b472-e772-4f0b-8465-0835980955ea" />

  <Card title="Practice Lab" icon="flask-conical" cta="Learn more" href="https://learn.kodekloud.com/user/courses/learn-by-doing-hashicorp-nomad/module/bbb9e697-2e59-4591-b750-678ef12293d3/lesson/4648a63d-9daa-45f6-bbea-7b89719682b0" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.