Not understanding jobs vs groups vs tasks

I haven’t been able to find any good explanation of how these abstractions are supposed to work. The docs just glance over them pretty quickly.

How are they supposed to be related? Am I supposed to put all tasks that are dependent upon each other in the same group? When would I have multiple groups per job?

Jobs are collections of groups. Groups are collections of tasks which execute on the same Nomad client. Tasks are the atomic unit of work. Does that help?

It doesn’t really explain when I would group anything together.

Jobs are collections of groups.

So should I just put all of my groups into one huge job file? How should I separate jobs?

Groups are collections of tasks which execute on the same Nomad client .

Why would I want several tasks to execute on the same client? I thought one of the purposes of Nomad was to abstract where your service is running, so you tell Nomad to run something and it will just figure it out.

By constraining several tasks to one client, isn’t that making Nomad less flexible? And what is the advantage?

Tasks are the atomic unit of work.

My understand of a task is that a task is pretty similar to a service, and can be a service if other tasks need to access them, like APIs, but if a task doesn’t need to be open some port to allow other tasks to call it then it is a task but not a service. Is that kind of correct?

Jobs are the unit of control; they’re the things on which the ACL system operates, for example. They’re also the place where priorities and constraints are set to inform the scheduler. If you take a look at the definition of the job, group and task stanzas it should start to make sense.

Maybe you need them to be on the same host for minimizing latency, or because they need to have the same failure domain, or they need to share a filesystem. There’re lot of reasons.

The term “service” is overloaded here and I suspect it’s confusing you.

A job can be scheduled as a service (which basically means Nomad always expects it to be running) vs. batch or system scheduling.

Groups and tasks can have service stanzas which means Nomad will register them with Consul.

Okay, I think that helps, at least gets me on the right track. Thank you! I appreciate it.

1 Like

Hi @cashihorp! I think @nhw76 has led you in a good direction. You might also want to check out https://www.nomadproject.io/docs/internals/architecture/ which has a glossary of the major “nouns”.

1 Like